@better-auth/mongo-adapter 1.7.0-beta.0 → 1.7.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +29 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -404,6 +404,31 @@ const mongodbAdapter = (db, config) => {
|
|
|
404
404
|
model
|
|
405
405
|
});
|
|
406
406
|
return (await db.collection(model).deleteMany(clause, { session })).deletedCount;
|
|
407
|
+
},
|
|
408
|
+
async consumeOne({ model, where }) {
|
|
409
|
+
const clause = convertWhereClause({
|
|
410
|
+
where,
|
|
411
|
+
model
|
|
412
|
+
});
|
|
413
|
+
return (await db.collection(model).findOneAndDelete(clause, {
|
|
414
|
+
session,
|
|
415
|
+
includeResultMetadata: true
|
|
416
|
+
}))?.value ?? null;
|
|
417
|
+
},
|
|
418
|
+
async incrementOne({ model, where, increment, set }) {
|
|
419
|
+
const clause = convertWhereClause({
|
|
420
|
+
where,
|
|
421
|
+
model
|
|
422
|
+
});
|
|
423
|
+
const update = {};
|
|
424
|
+
if (Object.keys(increment).length > 0) update.$inc = increment;
|
|
425
|
+
if (set && Object.keys(set).length > 0) update.$set = set;
|
|
426
|
+
if (!update.$inc && !update.$set) return db.collection(model).findOne(clause, { session });
|
|
427
|
+
return (await db.collection(model).findOneAndUpdate(clause, update, {
|
|
428
|
+
session,
|
|
429
|
+
returnDocument: "after",
|
|
430
|
+
includeResultMetadata: true
|
|
431
|
+
}))?.value ?? null;
|
|
407
432
|
}
|
|
408
433
|
};
|
|
409
434
|
};
|
|
@@ -425,7 +450,10 @@ const mongodbAdapter = (db, config) => {
|
|
|
425
450
|
try {
|
|
426
451
|
session.startTransaction();
|
|
427
452
|
const result = await cb(createAdapterFactory({
|
|
428
|
-
config:
|
|
453
|
+
config: {
|
|
454
|
+
...adapterOptions.config,
|
|
455
|
+
transaction: false
|
|
456
|
+
},
|
|
429
457
|
adapter: createCustomAdapter(db, session)
|
|
430
458
|
})(lazyOptions));
|
|
431
459
|
await session.commitTransaction();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/mongo-adapter",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.10",
|
|
4
4
|
"description": "Mongo adapter for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@better-auth/utils": "0.4.
|
|
38
|
+
"@better-auth/utils": "0.4.2",
|
|
39
39
|
"mongodb": "^6.0.0 || ^7.0.0",
|
|
40
|
-
"@better-auth/core": "^1.7.0-beta.
|
|
40
|
+
"@better-auth/core": "^1.7.0-beta.10"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"mongodb": {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@better-auth/utils": "0.4.
|
|
48
|
+
"@better-auth/utils": "0.4.2",
|
|
49
49
|
"mongodb": "^7.1.0",
|
|
50
50
|
"tsdown": "0.21.1",
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
|
-
"@better-auth/core": "1.7.0-beta.
|
|
52
|
+
"@better-auth/core": "1.7.0-beta.10"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown",
|