@jcbuisson/express-x-drizzle 1.0.4 → 1.0.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-drizzle",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "src/drizzle-plugins.mjs",
6
6
  "type": "module",
@@ -18,40 +18,6 @@ function whereToDrizzleFilters(table, filters) {
18
18
  return conditions.length ? and(...conditions) : undefined;
19
19
  }
20
20
 
21
- // ////////////////////////// DRIZZLE CRUD DATABSE PLUGIN //////////////////////////
22
-
23
- // export function drizzleDatabasePlugin(app, db, models) {
24
-
25
- // // add a database service for each model
26
- // for (const model of models) {
27
- // const modelName = getTableName(model)
28
-
29
- // app.createService(modelName, {
30
-
31
- // findUnique: async (where) => {
32
- // const rows = await db.select().from(model).where(whereToDrizzleFilters(model, where));
33
- // return rows[0] ?? null;
34
- // },
35
-
36
- // findMany: async (where) => {
37
- // return await db.select().from(model).where(whereToDrizzleFilters(model, where));
38
- // },
39
-
40
- // create: async (data) => {
41
- // return await db.insert(model).values(data).returning();
42
- // },
43
-
44
- // update: async (uid, data) => {
45
- // return await db.update(model).where(eq(model.uid, uid)).values(data).returning();
46
- // },
47
-
48
- // remove: async (uid) => {
49
- // return await db.delete(model).where(eq(model.uid, uid)).returning();
50
- // }
51
- // })
52
- // }
53
- // }
54
-
55
21
 
56
22
  ////////////////////////// DRIZZLE OFFLINE PLUGIN //////////////////////////
57
23
 
@@ -82,7 +48,7 @@ export function drizzleOfflinePlugin(app, db, metadata, models) {
82
48
 
83
49
  updateWithMeta: async (uid, data, updated_at) => {
84
50
  db.transaction(async (tx) => {
85
- const value = await tx.update(model).values(data).where(eq(model.uid, uid)).returning();
51
+ const value = await tx.update(model).set(data).where(eq(model.uid, uid)).returning();
86
52
  const meta = await tx.update(metadata).set({ updated_at }).where(eq(metadata.uid, uid)).returning();
87
53
  return [value, meta]
88
54
  })