chore: ttl of sort field lock

This commit is contained in:
Chareice 2024-08-16 13:41:49 +08:00 committed by mytharcher
parent c1db4f2e0c
commit ce353d7ba8

View File

@ -33,11 +33,17 @@ export class SortField extends Field {
} }
} }
await this.database.lockManager.runExclusive(this.context.collection.name, async () => { await this.database.lockManager.runExclusive(
this.context.collection.name,
async () => {
const max = await model.max<number, any>(name, { ...options, where }); const max = await model.max<number, any>(name, { ...options, where });
const newValue = (max || 0) + 1; const newValue = (max || 0) + 1;
instance.set(name, newValue); instance.set(name, newValue);
}); },
{
ttl: 2000,
},
);
}; };
onScopeChange = async (instance, options) => { onScopeChange = async (instance, options) => {