mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
Fix beforeCreate lifecycle
This commit is contained in:
parent
ee99a4ce80
commit
265fb1bdd9
@ -16,7 +16,7 @@
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.4",
|
||||
"mongoose": "^5.0.15",
|
||||
"mongoose": "^5.0.16",
|
||||
"mongoose-float": "^1.0.2",
|
||||
"pluralize": "^6.0.0",
|
||||
"strapi-utils": "3.0.0-alpha.12"
|
||||
@ -48,4 +48,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,9 +92,9 @@ module.exports = {
|
||||
|
||||
return module.exports.update.call(this, {
|
||||
[this.primaryKey]: entry[this.primaryKey],
|
||||
values: _.merge({
|
||||
values: _.assign({
|
||||
id: entry[this.primaryKey]
|
||||
}, params.values)
|
||||
}, params.values, entry)
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ module.exports = {
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const entry = await this.create(values)
|
||||
const request = await this.create(values)
|
||||
.catch((err) => {
|
||||
const message = err.message.split('index:');
|
||||
const field = _.words(_.last(message).split('_')[0]);
|
||||
@ -44,11 +44,13 @@ module.exports = {
|
||||
throw error;
|
||||
});
|
||||
|
||||
const entry = request.toJSON ? request.toJSON() : request;
|
||||
|
||||
return module.exports.update.call(this, {
|
||||
[this.primaryKey]: entry[this.primaryKey],
|
||||
values: _.merge({
|
||||
values: _.assign({
|
||||
id: entry[this.primaryKey]
|
||||
}, params.values)
|
||||
}, params.values, entry)
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user