@better-auth/prisma-adapter 1.6.20 → 1.6.21

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 +10 -5
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { createAdapterFactory } from "@better-auth/core/db/adapter";
2
2
  import { BetterAuthError } from "@better-auth/core/error";
3
3
  //#region src/prisma-adapter.ts
4
4
  function isPrismaNotFoundError(e) {
5
- return e?.code === "P2025" || e?.meta?.cause === "Record to delete does not exist.";
5
+ return e?.code === "P2025";
6
6
  }
7
7
  const prismaAdapter = (prisma, config) => {
8
8
  let lazyOptions = null;
@@ -261,10 +261,15 @@ const prismaAdapter = (prisma, config) => {
261
261
  where,
262
262
  action: "update"
263
263
  });
264
- return await db[model].update({
265
- where: whereClause,
266
- data: update
267
- });
264
+ try {
265
+ return await db[model].update({
266
+ where: whereClause,
267
+ data: update
268
+ });
269
+ } catch (e) {
270
+ if (isPrismaNotFoundError(e)) return null;
271
+ throw e;
272
+ }
268
273
  },
269
274
  async updateMany({ model, where, update }) {
270
275
  if (!db[model]) throw new BetterAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/prisma-adapter",
3
- "version": "1.6.20",
3
+ "version": "1.6.21",
4
4
  "description": "Prisma adapter for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "@better-auth/utils": "0.4.2",
39
39
  "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0",
40
40
  "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0",
41
- "@better-auth/core": "^1.6.20"
41
+ "@better-auth/core": "^1.6.21"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "@prisma/client": {
@@ -52,7 +52,7 @@
52
52
  "@better-auth/utils": "0.4.2",
53
53
  "tsdown": "0.21.1",
54
54
  "typescript": "^5.9.3",
55
- "@better-auth/core": "1.6.20"
55
+ "@better-auth/core": "1.6.21"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsdown",