surreal-better-auth 0.5.3 → 0.6.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/package.json +4 -4
- package/src/index.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "surreal-better-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Oskar Gmerek",
|
|
6
6
|
"url": "https://oskargmerek.com",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dayjs": "^1.11.13"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"better-auth": "^1.
|
|
42
|
-
"surrealdb": "^1.
|
|
43
|
-
"typescript": "^5.
|
|
41
|
+
"better-auth": "^1.1.15",
|
|
42
|
+
"surrealdb": "^1.1.0",
|
|
43
|
+
"typescript": "^5.7.3"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/index.ts
CHANGED
|
@@ -92,7 +92,7 @@ const createTransform = (options: BetterAuthOptions) => {
|
|
|
92
92
|
};
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
export const surrealAdapter = (db: Surreal) =>
|
|
95
|
+
export const surrealAdapter = (db: Surreal) => (options: BetterAuthOptions) => {
|
|
96
96
|
if (!db) {
|
|
97
97
|
throw new Error("SurrealDB adapter requires a SurrealDB client");
|
|
98
98
|
}
|
|
@@ -130,6 +130,13 @@ export const surrealAdapter = (db: Surreal) => async (options: BetterAuthOptions
|
|
|
130
130
|
const [results] = await db.query<[any[]]>(query);
|
|
131
131
|
return results.map(record => transformOutput(record, model));
|
|
132
132
|
},
|
|
133
|
+
count: async ({ model, where }) => {
|
|
134
|
+
const whereClause = where ? convertWhereClause(where, model) : '';
|
|
135
|
+
const query = `SELECT count(${whereClause}) FROM ${model} GROUP ALL`;
|
|
136
|
+
const [result] = await db.query<[any[]]>(query);
|
|
137
|
+
const res = result[0];
|
|
138
|
+
return res.count;
|
|
139
|
+
},
|
|
133
140
|
update: async ({ model, where, update }) => {
|
|
134
141
|
const whereClause = convertWhereClause(where, model);
|
|
135
142
|
const transformedUpdate = transformInput(update, model, "update");
|