mirror of
https://github.com/strapi/strapi.git
synced 2025-10-11 08:02:55 +00:00
Fix delete on Mongoose
This commit is contained in:
parent
bd16913b02
commit
cefaff4c45
@ -142,6 +142,7 @@ export class Edit extends React.Component {
|
||||
|
||||
if (isEmpty(formErrors)) {
|
||||
this.props.editRecord();
|
||||
|
||||
if (!isEmpty(this.props.location.search)) {
|
||||
router.push(replace(this.props.location.search, '?redirectUrl=', ''));
|
||||
} else {
|
||||
|
@ -190,7 +190,7 @@ export class List extends React.Component {
|
||||
history={this.props.history}
|
||||
primaryKey={currentModel.primaryKey || 'id'}
|
||||
handleDelete={this.toggleModalWarning}
|
||||
redirectUrl={`?redirectUrl=/plugins/content-manager/category/?page=${this.props.currentPage}&limit=${this.props.limit}&sort=${this.props.sort}`}
|
||||
redirectUrl={`?redirectUrl=/plugins/content-manager/${this.props.currentModelName.toLowerCase()}/?page=${this.props.currentPage}&limit=${this.props.limit}&sort=${this.props.sort}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ module.exports = {
|
||||
// Delete entry.
|
||||
return this
|
||||
.remove({
|
||||
[this.primaryKey]: params[this.primaryKey] || params._id
|
||||
[this.primaryKey]: params.id
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -87,7 +87,7 @@ module.exports = {
|
||||
const params = ctx.params;
|
||||
const response = await strapi.query(params.model).findOne({
|
||||
id: params.id
|
||||
})
|
||||
});
|
||||
|
||||
params.values = Object.keys(JSON.parse(JSON.stringify(response))).reduce((acc, current) => {
|
||||
const association = strapi.models[params.model].associations.filter(x => x.alias === current)[0];
|
||||
@ -100,8 +100,10 @@ module.exports = {
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// Run update to remove all relationships.
|
||||
await strapi.query(params.model).update(params);
|
||||
if (!_.isEmpty(params.values)) {
|
||||
// Run update to remove all relationships.
|
||||
await strapi.query(params.model).update(params);
|
||||
}
|
||||
|
||||
// Delete an entry using `queries` system
|
||||
const entryDeleted = await strapi.query(params.model).delete({
|
||||
|
Loading…
x
Reference in New Issue
Block a user