mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 12:23:05 +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}
|
||||
*/
|
||||
|
||||
add: (values) => {
|
||||
return <%= globalID %>.create(values);
|
||||
add: async (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]) {
|
||||
virtualFields.push(
|
||||
this.manageRelations(models, Model, {
|
||||
id: response[current][Model.primaryKey],
|
||||
this.manageRelations(models, models[details.model || details.collection], {
|
||||
_id: response[current][Model.primaryKey],
|
||||
values: {
|
||||
[details.via]: null
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user