Add group relation example

This commit is contained in:
Alexandre Bodin 2019-07-08 18:35:39 +02:00
parent 52a38e36db
commit ba5fc12ff9
4 changed files with 5 additions and 21 deletions

View File

@ -1,19 +0,0 @@
{
"name": "ingredient",
"collectionName": "ingredients",
"attributes": {
"name": {
"type": "string",
"required": true
},
"quantity": {
"type": "float",
"required": true
},
"picture": {
"model": "file",
"via": "related",
"plugin": "upload"
}
}
}

View File

@ -14,6 +14,9 @@
"model": "file",
"via": "related",
"plugin": "upload"
},
"article": {
"model": "articles"
}
}
}

View File

@ -14,7 +14,7 @@ module.exports = async ({ model, definition, ORM, GLOBALS }) => {
const joinTable = `${collectionName}_groups`;
const joinColumn = `${pluralize.singular(collectionName)}_${primaryKey}`;
const joinModel = ORM.Model.extend({
collectionName: joinTable,
tableName: joinTable,
slice() {
return this.morphTo(
'slice',

View File

@ -77,7 +77,7 @@ module.exports = strapi => {
ctx.status = error.status || 500;
ctx.body = _.get(ctx.body, 'isBoom')
? ctx.body || (error && error.message)
: Boom.wrap(error, ctx.status);
: Boom.boomify(error, { statusCode: ctx.status });
}
}