mirror of
https://github.com/strapi/strapi.git
synced 2025-09-01 04:42:58 +00:00
Fix update one to one mongoose relation
This commit is contained in:
parent
e038a238e7
commit
ceff284fb6
@ -48,8 +48,10 @@ module.exports = {
|
|||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
add: (values) => {
|
add: async (values) => {
|
||||||
return <%= globalID %>.create(values);
|
const data = await <%= globalID %>.create(_.omit(values, _.keys(_.groupBy(strapi.models.<%= id %>.associations, 'alias'))));
|
||||||
|
await strapi.hook.mongoose.load().manageRelations(strapi.models, <%= globalID %>, _.merge(_.clone(data), { values }));
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -369,8 +369,8 @@ module.exports = function (strapi) {
|
|||||||
|
|
||||||
if (response[current] && _.isObject(response[current]) && response[current][Model.primaryKey] !== value[current]) {
|
if (response[current] && _.isObject(response[current]) && response[current][Model.primaryKey] !== value[current]) {
|
||||||
virtualFields.push(
|
virtualFields.push(
|
||||||
this.manageRelations(models, Model, {
|
this.manageRelations(models, models[details.model || details.collection], {
|
||||||
id: response[current][Model.primaryKey],
|
_id: response[current][Model.primaryKey],
|
||||||
values: {
|
values: {
|
||||||
[details.via]: null
|
[details.via]: null
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user