mirror of
https://github.com/strapi/strapi.git
synced 2025-12-24 13:43:41 +00:00
Add group relation example
This commit is contained in:
parent
52a38e36db
commit
ba5fc12ff9
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,9 @@
|
||||
"model": "file",
|
||||
"via": "related",
|
||||
"plugin": "upload"
|
||||
},
|
||||
"article": {
|
||||
"model": "articles"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user