@better-auth/drizzle-adapter 1.7.0-rc.5 → 1.7.0
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/{generate-drizzle-schema-D5cxh_0D.mjs → generate-drizzle-schema-huQqmolx.mjs} +2 -2
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +3 -5
- package/dist/relations-v2/index.d.mts +2 -1
- package/dist/relations-v2/index.mjs +4 -6
- package/package.json +4 -4
- /package/dist/{query-builders-Btx2OekF.mjs → query-builders-D2eE7gbx.mjs} +0 -0
|
@@ -10,7 +10,7 @@ function convertToSnakeCase(str, camelCase) {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Convert a schema namespace into a valid JavaScript identifier so it can be
|
|
13
|
-
* used as the `const <name>Schema = pgSchema(...)` variable name.
|
|
13
|
+
* used as the `export const <name>Schema = pgSchema(...)` variable name.
|
|
14
14
|
* e.g. "my-auth" -> "myAuth", "123schema" -> "_123schema".
|
|
15
15
|
*/
|
|
16
16
|
function toValidIdentifier(str) {
|
|
@@ -35,7 +35,7 @@ const generateDrizzleSchema = async ({ options, file, provider, adapterConfig, c
|
|
|
35
35
|
if (databaseType === "pg" && schemaName) {
|
|
36
36
|
schemaVarName = `${toValidIdentifier(schemaName)}Schema`;
|
|
37
37
|
if (schemaVarName === "pgSchema") schemaVarName = "pgCustomSchema";
|
|
38
|
-
code += `\
|
|
38
|
+
code += `\nexport const ${schemaVarName} = pgSchema(${JSON.stringify(schemaName)});\n`;
|
|
39
39
|
}
|
|
40
40
|
const tableFunction = databaseType === "pg" && schemaName && schemaVarName ? `${schemaVarName}.table` : `${databaseType}Table`;
|
|
41
41
|
const getModelName = initGetModelName({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DBAdapter, DBAdapterDebugLogOption } from "@better-auth/core/db/adapter";
|
|
2
2
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
3
|
+
|
|
3
4
|
//#region src/drizzle-adapter.d.ts
|
|
4
5
|
interface DB {
|
|
5
6
|
[key: string]: any;
|
|
@@ -46,7 +47,7 @@ interface DrizzleAdapterConfig {
|
|
|
46
47
|
* Only applies to PostgreSQL. It will generate something like this:
|
|
47
48
|
*
|
|
48
49
|
* ```ts
|
|
49
|
-
* const authSchema = pgSchema("auth");
|
|
50
|
+
* export const authSchema = pgSchema("auth");
|
|
50
51
|
*
|
|
51
52
|
* export const user = authSchema.table("user", {...});
|
|
52
53
|
* export const session = authSchema.table("session", {...});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as insensitiveNe, i as insensitiveInArray, n as insensitiveEq, o as insensitiveNotInArray, r as insensitiveIlike } from "./query-builders-
|
|
1
|
+
import { a as insensitiveNe, i as insensitiveInArray, n as insensitiveEq, o as insensitiveNotInArray, r as insensitiveIlike } from "./query-builders-D2eE7gbx.mjs";
|
|
2
2
|
import { createAdapterFactory } from "@better-auth/core/db/adapter";
|
|
3
3
|
import { logger } from "@better-auth/core/env";
|
|
4
4
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
@@ -299,8 +299,7 @@ const drizzleAdapter = (db, config) => {
|
|
|
299
299
|
async create({ model, data: values }) {
|
|
300
300
|
const schemaModel = getSchema(model);
|
|
301
301
|
checkMissingFields(schemaModel, model, values);
|
|
302
|
-
|
|
303
|
-
return await withReturning(model, builder, values);
|
|
302
|
+
return await withReturning(model, db.insert(schemaModel).values(values), values);
|
|
304
303
|
},
|
|
305
304
|
async findOne({ model, where, select, join }) {
|
|
306
305
|
const schemaModel = getSchema(model);
|
|
@@ -431,8 +430,7 @@ const drizzleAdapter = (db, config) => {
|
|
|
431
430
|
async update({ model, where, update: values }) {
|
|
432
431
|
const schemaModel = getSchema(model);
|
|
433
432
|
const clause = convertWhereClause(where, model);
|
|
434
|
-
|
|
435
|
-
return await withReturning(model, builder, values, where);
|
|
433
|
+
return await withReturning(model, db.update(schemaModel).set(values).where(...clause), values, where);
|
|
436
434
|
},
|
|
437
435
|
async updateMany({ model, where, update: values }) {
|
|
438
436
|
const schemaModel = getSchema(model);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DBAdapter, DBAdapterDebugLogOption } from "@better-auth/core/db/adapter";
|
|
2
2
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
3
|
+
|
|
3
4
|
//#region src/relations-v2/index.d.ts
|
|
4
5
|
interface DB {
|
|
5
6
|
[key: string]: any;
|
|
@@ -46,7 +47,7 @@ interface DrizzleAdapterConfig {
|
|
|
46
47
|
* Only applies to PostgreSQL. It will generate something like this:
|
|
47
48
|
*
|
|
48
49
|
* ```ts
|
|
49
|
-
* const authSchema = pgSchema("auth");
|
|
50
|
+
* export const authSchema = pgSchema("auth");
|
|
50
51
|
*
|
|
51
52
|
* export const user = authSchema.table("user", {...});
|
|
52
53
|
* export const session = authSchema.table("session", {...});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as insensitiveNe, i as insensitiveInArray, n as insensitiveEq, o as insensitiveNotInArray, t as escapedLike } from "../query-builders-
|
|
1
|
+
import { a as insensitiveNe, i as insensitiveInArray, n as insensitiveEq, o as insensitiveNotInArray, t as escapedLike } from "../query-builders-D2eE7gbx.mjs";
|
|
2
2
|
import { createAdapterFactory } from "@better-auth/core/db/adapter";
|
|
3
3
|
import { logger } from "@better-auth/core/env";
|
|
4
4
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
@@ -278,8 +278,7 @@ const drizzleAdapter = (db, config) => {
|
|
|
278
278
|
async create({ model, data: values }) {
|
|
279
279
|
const schemaModel = getSchema(model);
|
|
280
280
|
checkMissingFields(schemaModel, model, values);
|
|
281
|
-
|
|
282
|
-
return await withReturning(model, builder, values);
|
|
281
|
+
return await withReturning(model, db.insert(schemaModel).values(values), values);
|
|
283
282
|
},
|
|
284
283
|
async findOne({ model, where, select, join }) {
|
|
285
284
|
const schemaModel = getSchema(model);
|
|
@@ -416,8 +415,7 @@ const drizzleAdapter = (db, config) => {
|
|
|
416
415
|
async update({ model, where, update: values }) {
|
|
417
416
|
const schemaModel = getSchema(model);
|
|
418
417
|
const clause = convertWhereClause(where, model);
|
|
419
|
-
|
|
420
|
-
return await withReturning(model, builder, values, where);
|
|
418
|
+
return await withReturning(model, db.update(schemaModel).set(values).where(...clause), values, where);
|
|
421
419
|
},
|
|
422
420
|
async updateMany({ model, where, update: values }) {
|
|
423
421
|
const schemaModel = getSchema(model);
|
|
@@ -507,7 +505,7 @@ const drizzleAdapter = (db, config) => {
|
|
|
507
505
|
return (await db.update(schemaModel).set(assignments).where(inArray(idColumn, targetIds)).returning())[0] ?? null;
|
|
508
506
|
},
|
|
509
507
|
async createSchema(props) {
|
|
510
|
-
const { generateDrizzleSchema } = await import("../generate-drizzle-schema-
|
|
508
|
+
const { generateDrizzleSchema } = await import("../generate-drizzle-schema-huQqmolx.mjs");
|
|
511
509
|
return await generateDrizzleSchema({
|
|
512
510
|
adapterConfig: config,
|
|
513
511
|
options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/drizzle-adapter",
|
|
3
|
-
"version": "1.7.0
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/better-auth/better-auth/issues"
|
|
6
6
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@better-auth/utils": "0.4.2",
|
|
47
47
|
"drizzle-orm": "^0.45.2 || >=1.0.0-rc.1 <2.0.0",
|
|
48
|
-
"@better-auth/core": "^1.7.0
|
|
48
|
+
"@better-auth/core": "^1.7.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"drizzle-orm": {
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@better-auth/utils": "0.4.2",
|
|
57
57
|
"drizzle-orm": "^0.45.2",
|
|
58
|
-
"tsdown": "0.
|
|
58
|
+
"tsdown": "0.21.10",
|
|
59
59
|
"typescript": "^6.0.3",
|
|
60
|
-
"@better-auth/core": "1.7.0
|
|
60
|
+
"@better-auth/core": "1.7.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsdown",
|
|
File without changes
|