Fix conflict

This commit is contained in:
cyril lopez 2017-12-13 16:47:35 +01:00
commit b541e6cc4f
3 changed files with 6 additions and 4 deletions

View File

@ -36,7 +36,7 @@ module.exports = {
} catch (e) {
// Collection undefined try to get the collection based on collectionIdentity
if (typeof strapi !== 'undefined') {
collection = _.get(strapi.bookshelf.collections, collectionIdentity);
collection = _.get(strapi, `bookshelf.collections.${collectionIdentity}`);
}
// Impossible to match collectionIdentity before, try to use idAttribute

View File

@ -67,7 +67,7 @@ module.exports = {
update: async function (params) {
const virtualFields = [];
const response = await module.exports.findOne.call(this, params);
// Only update fields which are on this document.
const values = params.parseRelationships === false ? params.values : Object.keys(JSON.parse(JSON.stringify(params.values))).reduce((acc, current) => {
const association = this.associations.filter(x => x.alias === current)[0];
@ -211,6 +211,7 @@ module.exports = {
switch (association.nature) {
case 'oneToOne':
case 'oneToMany':
case 'manyToOne':
return module.exports.update.call(this, params);
case 'manyToMany':
return this.forge({
@ -233,6 +234,7 @@ module.exports = {
switch (association.nature) {
case 'oneToOne':
case 'oneToMany':
case 'manyToOne':
return module.exports.update.call(this, params);
case 'manyToMany':
return this.forge({

View File

@ -29,8 +29,8 @@
"type": "integer"
},
"posts": {
"collection": "post",
"via": "author"
"collection": "post",
"via": "author"
}
}
}