import { MongodbLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
import { MongoClient } from "mongodb";
(async () => {
const client = await MongoClient.connect("YOUR_MONGODB_CONNECTION_STRING");
const database = client.db("database");
const lockAdapter = new MongodbLockAdapter({
database,
rootGroup: "@global"
});
await lockAdapter.init();
})();
The withGroup method returns a new IDatabaseLockAdapter instance that groups locks together. Only locks in the same group will be acquired and released, leaving locks outside the group unaffected.
To utilize the MongodbLockAdapter, you must install the "mongodb" package.
Note in order to use MongodbLockAdapter correctly, ensure you use a single, consistent database across all server instances.
IMPORT_PATH:
"@daiso-tech/core/lock/implementations/adapters"