fix(plugin-data-source-main): fix lock usage

This commit is contained in:
mytharcher 2024-08-22 21:30:52 +08:00
parent 2251742b86
commit 15593b5185

View File

@ -316,7 +316,7 @@ export class PluginDataSourceMainServer extends Plugin {
this.app.db.on('fields.beforeDestroy', beforeDestroyForeignKey(this.app.db)); this.app.db.on('fields.beforeDestroy', beforeDestroyForeignKey(this.app.db));
this.app.db.on('fields.beforeDestroy', async (model: FieldModel, options) => { this.app.db.on('fields.beforeDestroy', async (model: FieldModel, options) => {
const lockKey = `${this.name}:fields.beforeDestroy:${model.get('collectionName')}:${model.get('name')}`; const lockKey = `${this.name}:fields.beforeDestroy:${model.get('collectionName')}`;
await this.app.lockManager.runExclusive(lockKey, async () => { await this.app.lockManager.runExclusive(lockKey, async () => {
await model.remove(options); await model.remove(options);