@better-auth/mongo-adapter 1.7.0-beta.4 → 1.7.0-beta.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +15 -0
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -414,6 +414,21 @@ const mongodbAdapter = (db, config) => {
414
414
  session,
415
415
  includeResultMetadata: true
416
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;
417
432
  }
418
433
  };
419
434
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/mongo-adapter",
3
- "version": "1.7.0-beta.4",
3
+ "version": "1.7.0-beta.6",
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.1",
38
+ "@better-auth/utils": "0.4.2",
39
39
  "mongodb": "^6.0.0 || ^7.0.0",
40
- "@better-auth/core": "^1.7.0-beta.4"
40
+ "@better-auth/core": "^1.7.0-beta.6"
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.1",
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.4"
52
+ "@better-auth/core": "1.7.0-beta.6"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsdown",