Skip to content

Commit 5ba0c0e

Browse files
committed
fix mongo delete record filter
1 parent 08154a9 commit 5ba0c0e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adminforth/dataConnectors/mongo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
222222
}
223223

224224
async deleteRecord({ resource, recordId }): Promise<boolean> {
225-
const primaryKey = this.getPrimaryKey(resource);
226225
const collection = this.client.db().collection(resource.table);
227-
const res = await collection.deleteOne({ [primaryKey]: recordId });
226+
const primaryKeyColumn = resource.dataSourceColumns.find((col) => col.name === this.getPrimaryKey(resource));
227+
const res = await collection.deleteOne({ [primaryKeyColumn.name]: this.setFieldValue(primaryKeyColumn, recordId) });
228228
return res.deletedCount > 0;
229229
}
230230

0 commit comments

Comments
 (0)