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