vinojs 0.1.0 → 0.1.2

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 (115) hide show
  1. package/dist/client.mjs +1 -1
  2. package/dist/{compile-Lxl_tdxL.mjs → compile-glNMkyyx.mjs} +3 -47
  3. package/dist/compile-glNMkyyx.mjs.map +1 -0
  4. package/dist/{definePage-Ba4r-TFh.mjs → definePage--9Pz7rHs.mjs} +29 -7
  5. package/dist/definePage--9Pz7rHs.mjs.map +1 -0
  6. package/dist/defineServerFn-H-bz7xBX.mjs +47 -0
  7. package/dist/defineServerFn-H-bz7xBX.mjs.map +1 -0
  8. package/dist/factory-CVT0-OZw.d.mts +187 -0
  9. package/dist/factory-CVT0-OZw.d.mts.map +1 -0
  10. package/dist/factory.d.mts +2 -0
  11. package/dist/factory.mjs +153 -0
  12. package/dist/factory.mjs.map +1 -0
  13. package/dist/vino.d.mts +4 -103
  14. package/dist/vino.d.mts.map +1 -1
  15. package/dist/vino.mjs +8 -3
  16. package/dist/vino.mjs.map +1 -1
  17. package/dist/vite.mjs +3 -2
  18. package/dist/vite.mjs.map +1 -1
  19. package/package.json +5 -1
  20. package/dist/compile-Lxl_tdxL.mjs.map +0 -1
  21. package/dist/definePage-Ba4r-TFh.mjs.map +0 -1
  22. package/examples/basic/dist/client/.assetsignore +0 -2
  23. package/examples/basic/dist/client/about.html +0 -1
  24. package/examples/basic/dist/client/admin.html +0 -1
  25. package/examples/basic/dist/client/assets/Counter-BvqMZKON.js +0 -1
  26. package/examples/basic/dist/client/assets/_slug_-CYpOSbrn.js +0 -1
  27. package/examples/basic/dist/client/assets/about-BZXRzUyv.js +0 -1
  28. package/examples/basic/dist/client/assets/admin-DRE7uh2s.js +0 -1
  29. package/examples/basic/dist/client/assets/client-B6nFkut5.js +0 -1
  30. package/examples/basic/dist/client/assets/client-pages-Bc6cNZAm.js +0 -2
  31. package/examples/basic/dist/client/assets/components-DX9r6vHn.js +0 -1
  32. package/examples/basic/dist/client/assets/components-DsWJ6F73.js +0 -2
  33. package/examples/basic/dist/client/assets/counter-DBpvln_F.js +0 -1
  34. package/examples/basic/dist/client/assets/dom-B5sHIJ1E.js +0 -1
  35. package/examples/basic/dist/client/assets/honoto-9UtdLp4J.js +0 -33
  36. package/examples/basic/dist/client/assets/honoto-client-DEh86_WZ.css +0 -1
  37. package/examples/basic/dist/client/assets/honoto-client.js +0 -2
  38. package/examples/basic/dist/client/assets/hooks-Cz6AT21d.js +0 -1
  39. package/examples/basic/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
  40. package/examples/basic/dist/client/counter.html +0 -1
  41. package/examples/basic/dist/client/index.html +0 -1
  42. package/examples/basic/dist/client/jobs.html +0 -1
  43. package/examples/basic/dist/ssr/.vite/manifest.json +0 -140
  44. package/examples/basic/dist/ssr/assets/_slug_-CY3-kffX.js +0 -46
  45. package/examples/basic/dist/ssr/assets/about-CTDjNhkO.js +0 -15
  46. package/examples/basic/dist/ssr/assets/admin-DvS-UGJx.js +0 -26
  47. package/examples/basic/dist/ssr/assets/constants-UoriGYcX-CUecBFMT.js +0 -6
  48. package/examples/basic/dist/ssr/assets/counter-DfIbc9Sp.js +0 -30
  49. package/examples/basic/dist/ssr/assets/honoto-CA313cVy.js +0 -2129
  50. package/examples/basic/dist/ssr/assets/jobs-D9hh-UO9.js +0 -42
  51. package/examples/basic/dist/ssr/assets/jsx-CgYLQazd.js +0 -1080
  52. package/examples/basic/dist/ssr/assets/jsx-dev-runtime-BlUda7H8.js +0 -742
  53. package/examples/basic/dist/ssr/assets/jsx-renderer-CzZcZPnS.js +0 -65
  54. package/examples/basic/dist/ssr/assets/layout-DYvLwr2u.js +0 -53
  55. package/examples/basic/dist/ssr/assets/pages-DB6jeyrt.js +0 -53
  56. package/examples/basic/dist/ssr/assets/rolldown-runtime-D7D4PA-g.js +0 -13
  57. package/examples/basic/dist/ssr/assets/ssr-hooks-CBQr0cdH.js +0 -7
  58. package/examples/basic/dist/ssr/index.js +0 -22
  59. package/examples/basic/dist/ssr/wrangler.json +0 -1
  60. package/examples/full/dist/client/.assetsignore +0 -2
  61. package/examples/full/dist/client/assets/BookmarkButton-py0xGxgl.js +0 -1
  62. package/examples/full/dist/client/assets/_slug_-DZUFsE9O.js +0 -1
  63. package/examples/full/dist/client/assets/auth-client-D2Wtuobe.js +0 -1
  64. package/examples/full/dist/client/assets/bun-sqlite-dialect-C7ftEUSI-CsHdUKBY.js +0 -1
  65. package/examples/full/dist/client/assets/client-B6nFkut5.js +0 -1
  66. package/examples/full/dist/client/assets/client-pages-fshKs747.js +0 -2
  67. package/examples/full/dist/client/assets/components-DX9r6vHn.js +0 -1
  68. package/examples/full/dist/client/assets/components-S_-rWrKi.js +0 -2
  69. package/examples/full/dist/client/assets/d1-sqlite-dialect-BZmaVTp8-FPCaMZqX.js +0 -1
  70. package/examples/full/dist/client/assets/default-query-compiler-CUdqIu1h.js +0 -1
  71. package/examples/full/dist/client/assets/dist-BoGTNvkC.js +0 -1
  72. package/examples/full/dist/client/assets/dom-DCd3wYW7.js +0 -1
  73. package/examples/full/dist/client/assets/factory-Bgf4EtLx.js +0 -8
  74. package/examples/full/dist/client/assets/honoto-client-BSvNAnxN.css +0 -1
  75. package/examples/full/dist/client/assets/honoto-client.js +0 -2
  76. package/examples/full/dist/client/assets/hooks-Cz6AT21d.js +0 -1
  77. package/examples/full/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
  78. package/examples/full/dist/client/assets/kysely-adapter-BHhasAnc.js +0 -1
  79. package/examples/full/dist/client/assets/kysely-migration-tables-DFfmKhq--U5ujlMwE.js +0 -1
  80. package/examples/full/dist/client/assets/node-sqlite-dialect-DJDXH5Ot.js +0 -1
  81. package/examples/full/dist/client/assets/pages-CUQx6Eus.js +0 -1
  82. package/examples/full/dist/client/assets/saved-jIi74ncJ.js +0 -1
  83. package/examples/full/dist/client/assets/session-B-accyM3.js +0 -611
  84. package/examples/full/dist/client/assets/sign-in-BelI3gSs.js +0 -1
  85. package/examples/full/dist/client/assets/sign-up-pR94lfdu.js +0 -1
  86. package/examples/full/dist/client/index.html +0 -1
  87. package/examples/full/dist/client/saved.html +0 -1
  88. package/examples/full/dist/client/sign-in.html +0 -1
  89. package/examples/full/dist/client/sign-up.html +0 -1
  90. package/examples/full/dist/ssr/.dev.vars +0 -1
  91. package/examples/full/dist/ssr/.vite/manifest.json +0 -219
  92. package/examples/full/dist/ssr/assets/BookmarkButton-KS7z5_vi.js +0 -298
  93. package/examples/full/dist/ssr/assets/_slug_-rRStRaAN.js +0 -89
  94. package/examples/full/dist/ssr/assets/auth-DSFZ4iak.js +0 -31434
  95. package/examples/full/dist/ssr/assets/auth-client-BFSBVoML.js +0 -894
  96. package/examples/full/dist/ssr/assets/bun-sqlite-dialect-C7ftEUSI-BeXpIqKl.js +0 -162
  97. package/examples/full/dist/ssr/assets/compiled-query-DmoyCh28.js +0 -8410
  98. package/examples/full/dist/ssr/assets/d1-sqlite-dialect-BZmaVTp8-CjJdvL94.js +0 -114
  99. package/examples/full/dist/ssr/assets/default-query-compiler-D7xOzCCJ.js +0 -1727
  100. package/examples/full/dist/ssr/assets/dist-LmmDoNdk.js +0 -6832
  101. package/examples/full/dist/ssr/assets/dist-kFDN1l4Z.js +0 -342
  102. package/examples/full/dist/ssr/assets/factory-AD6s9SIW.js +0 -2079
  103. package/examples/full/dist/ssr/assets/jsx-renderer-mMLf5XLN.js +0 -1926
  104. package/examples/full/dist/ssr/assets/kysely-adapter-BCLenpM8.js +0 -2
  105. package/examples/full/dist/ssr/assets/kysely-migration-tables-DFfmKhq--BtVr6hRe.js +0 -17
  106. package/examples/full/dist/ssr/assets/layout-mVA7qP4j.js +0 -44
  107. package/examples/full/dist/ssr/assets/node-sqlite-dialect-D-wtYAD7.js +0 -162
  108. package/examples/full/dist/ssr/assets/pages-Do5kR_Ia.js +0 -147
  109. package/examples/full/dist/ssr/assets/saved-Dr4pP6B5.js +0 -111
  110. package/examples/full/dist/ssr/assets/session-BvIpX7tr.js +0 -13
  111. package/examples/full/dist/ssr/assets/sign-in-22pzTnJE.js +0 -115
  112. package/examples/full/dist/ssr/assets/sign-up-CN4j8Qg1.js +0 -117
  113. package/examples/full/dist/ssr/assets/sqlite-adapter-DVlms5wO.js +0 -79
  114. package/examples/full/dist/ssr/index.js +0 -97
  115. package/examples/full/dist/ssr/wrangler.json +0 -1
@@ -1,342 +0,0 @@
1
- import { C as logger, t as createAdapterFactory } from "./factory-AD6s9SIW.js";
2
- //#region ../../node_modules/.pnpm/@better-auth+memory-adapter@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@bet_e2933db5834ce8852fe6fb6f83f04210/node_modules/@better-auth/memory-adapter/dist/index.mjs
3
- /**
4
- * Case-insensitive in-memory comparison helpers.
5
- * Used when evaluating where clauses in the memory adapter.
6
- */
7
- function insensitiveCompare(a, b) {
8
- if (typeof a === "string" && typeof b === "string") return a.toLowerCase() === b.toLowerCase();
9
- return a === b;
10
- }
11
- function insensitiveIn(recordVal, values) {
12
- if (typeof recordVal !== "string") return values.includes(recordVal);
13
- return values.some((v) => typeof v === "string" && recordVal.toLowerCase() === v.toLowerCase());
14
- }
15
- function insensitiveNotIn(recordVal, values) {
16
- return !insensitiveIn(recordVal, values);
17
- }
18
- function insensitiveContains(recordVal, value) {
19
- if (typeof recordVal !== "string" || typeof value !== "string") return false;
20
- return recordVal.toLowerCase().includes(value.toLowerCase());
21
- }
22
- function insensitiveStartsWith(recordVal, value) {
23
- if (typeof recordVal !== "string" || typeof value !== "string") return false;
24
- return recordVal.toLowerCase().startsWith(value.toLowerCase());
25
- }
26
- function insensitiveEndsWith(recordVal, value) {
27
- if (typeof recordVal !== "string" || typeof value !== "string") return false;
28
- return recordVal.toLowerCase().endsWith(value.toLowerCase());
29
- }
30
- /**
31
- * Index a table's rows by their `id` for row-level reconciliation. Every
32
- * better-auth row carries an `id` (the adapter's join logic already keys on
33
- * `record.id`), so the id is a stable identity for the three-way merge.
34
- */
35
- function indexById(rows) {
36
- const byId = /* @__PURE__ */ new Map();
37
- for (const row of rows) byId.set(row.id, row);
38
- return byId;
39
- }
40
- /**
41
- * Commit a transaction onto the live database with a three-way merge so a
42
- * concurrent write that interleaved at an `await` point survives.
43
- *
44
- * `base` is the snapshot taken when the transaction started; `clone` is that
45
- * snapshot after the transaction mutated it; `target` is the live database as
46
- * it stands now (possibly carrying concurrent writes). Replaying only the
47
- * `base -> clone` delta onto `target` applies the transaction's own creates,
48
- * updates, and deletes without disturbing rows or tables the transaction never
49
- * touched. A row the transaction did not change keeps the live version, so a
50
- * concurrent edit to a different row is preserved. A row the transaction did
51
- * change wins last-writer-wins over a concurrent edit to the same row, which is
52
- * acceptable for an in-memory development adapter; isolation is guaranteed only
53
- * at row/table granularity.
54
- *
55
- * `target` is mutated in place so any reference held elsewhere (for example the
56
- * `db` object the caller passed to `memoryAdapter`) stays valid.
57
- */
58
- function mergeTransactionInto(target, base, clone) {
59
- const models = /* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(clone)]);
60
- for (const model of models) {
61
- if (!(model in clone)) {
62
- delete target[model];
63
- continue;
64
- }
65
- const baseById = indexById(base[model] ?? []);
66
- const cloneRows = clone[model] ?? [];
67
- const cloneById = indexById(cloneRows);
68
- const liveRows = target[model] ?? [];
69
- const merged = [];
70
- const placed = /* @__PURE__ */ new Set();
71
- for (const liveRow of liveRows) {
72
- const id = liveRow.id;
73
- const baseRow = baseById.get(id);
74
- const cloneRow = cloneById.get(id);
75
- if (baseRow !== void 0 && cloneRow === void 0) continue;
76
- if (cloneRow !== void 0 && rowChanged(baseRow, cloneRow)) merged.push(cloneRow);
77
- else merged.push(liveRow);
78
- placed.add(id);
79
- }
80
- for (const cloneRow of cloneRows) if (!baseById.has(cloneRow.id) && !placed.has(cloneRow.id)) merged.push(cloneRow);
81
- target[model] = merged;
82
- }
83
- }
84
- /**
85
- * Whether the transaction mutated a row, comparing its pre-transaction
86
- * snapshot to its post-transaction state. Rows hold scalar columns and
87
- * adapter-serializable values, so JSON equality reliably tells a
88
- * transaction-made edit apart from an untouched row.
89
- */
90
- function rowChanged(baseRow, cloneRow) {
91
- if (baseRow === void 0) return true;
92
- return JSON.stringify(baseRow) !== JSON.stringify(cloneRow);
93
- }
94
- var memoryAdapter = (db, config) => {
95
- let lazyOptions = null;
96
- /**
97
- * Build an adapter factory whose operations read and write `activeDb`.
98
- * The non-transactional adapter targets the live `db`. A transaction
99
- * targets an isolated clone so its uncommitted writes are invisible to
100
- * concurrent operations against the live `db`. A failed transaction leaves
101
- * the live `db` untouched, and a committed one replays only its own
102
- * row/table changes, so a concurrent write that interleaved at an `await`
103
- * point survives either outcome. Isolation is at row/table granularity:
104
- * the in-memory adapter does not serialize writes, so two operations that
105
- * edit the same row resolve last-writer-wins. It is built for development
106
- * and tests, not production concurrency control.
107
- */
108
- const buildAdapterFactory = (activeDb) => createAdapterFactory({
109
- config: {
110
- adapterId: "memory",
111
- adapterName: "Memory Adapter",
112
- usePlural: false,
113
- debugLogs: config?.debugLogs || false,
114
- supportsArrays: true,
115
- customTransformInput(props) {
116
- if (props.options.advanced?.database?.generateId === "serial" && props.field === "id" && props.action === "create") return activeDb[props.model].length + 1;
117
- return props.data;
118
- },
119
- transaction: async (cb) => {
120
- const base = structuredClone(activeDb);
121
- const clone = structuredClone(activeDb);
122
- const result = await cb(buildAdapterFactory(clone)(lazyOptions));
123
- mergeTransactionInto(activeDb, base, clone);
124
- return result;
125
- }
126
- },
127
- adapter: ({ getFieldName, getDefaultFieldName, options, getModelName }) => {
128
- const applySortToRecords = (records, sortBy, model) => {
129
- if (!sortBy) return records;
130
- return records.sort((a, b) => {
131
- const field = getFieldName({
132
- model,
133
- field: sortBy.field
134
- });
135
- const aValue = a[field];
136
- const bValue = b[field];
137
- let comparison = 0;
138
- if (aValue == null && bValue == null) comparison = 0;
139
- else if (aValue == null) comparison = -1;
140
- else if (bValue == null) comparison = 1;
141
- else if (typeof aValue === "string" && typeof bValue === "string") comparison = aValue.localeCompare(bValue);
142
- else if (aValue instanceof Date && bValue instanceof Date) comparison = aValue.getTime() - bValue.getTime();
143
- else if (typeof aValue === "number" && typeof bValue === "number") comparison = aValue - bValue;
144
- else if (typeof aValue === "boolean" && typeof bValue === "boolean") comparison = aValue === bValue ? 0 : aValue ? 1 : -1;
145
- else comparison = String(aValue).localeCompare(String(bValue));
146
- return sortBy.direction === "asc" ? comparison : -comparison;
147
- });
148
- };
149
- function convertWhereClause(where, model, join, select) {
150
- const baseRecords = (() => {
151
- const table = activeDb[model];
152
- if (!table) {
153
- logger.error(`[MemoryAdapter] Model ${model} not found in the DB`, Object.keys(activeDb));
154
- throw new Error(`Model ${model} not found`);
155
- }
156
- const evalClause = (record, clause) => {
157
- const { field, value, operator, mode = "sensitive" } = clause;
158
- const isInsensitive = mode === "insensitive" && (typeof value === "string" || Array.isArray(value) && value.every((v) => typeof v === "string"));
159
- switch (operator) {
160
- case "in":
161
- if (!Array.isArray(value)) throw new Error("Value must be an array");
162
- if (isInsensitive) return insensitiveIn(record[field], value);
163
- return value.includes(record[field]);
164
- case "not_in":
165
- if (!Array.isArray(value)) throw new Error("Value must be an array");
166
- if (isInsensitive) return insensitiveNotIn(record[field], value);
167
- return !value.includes(record[field]);
168
- case "contains":
169
- if (isInsensitive) return insensitiveContains(record[field], value);
170
- return record[field]?.includes(value);
171
- case "starts_with":
172
- if (isInsensitive) return insensitiveStartsWith(record[field], value);
173
- return record[field].startsWith(value);
174
- case "ends_with":
175
- if (isInsensitive) return insensitiveEndsWith(record[field], value);
176
- return record[field].endsWith(value);
177
- case "ne": return isInsensitive ? !insensitiveCompare(record[field], value) : record[field] !== value;
178
- case "gt": return value != null && Boolean(record[field] > value);
179
- case "gte": return value != null && Boolean(record[field] >= value);
180
- case "lt": return value != null && Boolean(record[field] < value);
181
- case "lte": return value != null && Boolean(record[field] <= value);
182
- default:
183
- if (isInsensitive) return insensitiveCompare(record[field], value);
184
- if (value === null) return record[field] == null;
185
- return record[field] === value;
186
- }
187
- };
188
- let records = table.filter((record) => {
189
- if (!where.length || where.length === 0) return true;
190
- let result = evalClause(record, where[0]);
191
- for (const clause of where) {
192
- const clauseResult = evalClause(record, clause);
193
- if (clause.connector === "OR") result = result || clauseResult;
194
- else result = result && clauseResult;
195
- }
196
- return result;
197
- });
198
- if (select?.length && select.length > 0) records = records.map((record) => Object.fromEntries(Object.entries(record).filter(([key]) => select.includes(getDefaultFieldName({
199
- model,
200
- field: key
201
- })))));
202
- return records;
203
- })();
204
- if (!join) return baseRecords;
205
- const grouped = /* @__PURE__ */ new Map();
206
- const seenIds = /* @__PURE__ */ new Map();
207
- for (const baseRecord of baseRecords) {
208
- const baseId = String(baseRecord.id);
209
- if (!grouped.has(baseId)) {
210
- const nested = { ...baseRecord };
211
- for (const [joinModel, joinAttr] of Object.entries(join)) {
212
- const joinModelName = getModelName(joinModel);
213
- if (joinAttr.relation === "one-to-one") nested[joinModelName] = null;
214
- else {
215
- nested[joinModelName] = [];
216
- seenIds.set(`${baseId}-${joinModel}`, /* @__PURE__ */ new Set());
217
- }
218
- }
219
- grouped.set(baseId, nested);
220
- }
221
- const nestedEntry = grouped.get(baseId);
222
- for (const [joinModel, joinAttr] of Object.entries(join)) {
223
- const joinModelName = getModelName(joinModel);
224
- const joinTable = activeDb[joinModelName];
225
- if (!joinTable) {
226
- logger.error(`[MemoryAdapter] JoinOption model ${joinModelName} not found in the DB`, Object.keys(activeDb));
227
- throw new Error(`JoinOption model ${joinModelName} not found`);
228
- }
229
- const matchingRecords = joinTable.filter((joinRecord) => joinRecord[joinAttr.on.to] === baseRecord[joinAttr.on.from]);
230
- if (joinAttr.relation === "one-to-one") nestedEntry[joinModelName] = matchingRecords[0] || null;
231
- else {
232
- const seenSet = seenIds.get(`${baseId}-${joinModel}`);
233
- const limit = joinAttr.limit ?? 100;
234
- let count = 0;
235
- for (const matchingRecord of matchingRecords) {
236
- if (count >= limit) break;
237
- if (!seenSet.has(matchingRecord.id)) {
238
- nestedEntry[joinModelName].push(matchingRecord);
239
- seenSet.add(matchingRecord.id);
240
- count++;
241
- }
242
- }
243
- }
244
- }
245
- }
246
- return Array.from(grouped.values());
247
- }
248
- return {
249
- create: async ({ model, data }) => {
250
- if (options.advanced?.database?.generateId === "serial") data.id = activeDb[getModelName(model)].length + 1;
251
- if (!activeDb[model]) activeDb[model] = [];
252
- activeDb[model].push(data);
253
- return data;
254
- },
255
- findOne: async ({ model, where, select, join }) => {
256
- const res = convertWhereClause(where, model, join, select);
257
- if (join) {
258
- const resArray = res;
259
- if (!resArray.length) return null;
260
- return resArray[0];
261
- }
262
- return res[0] || null;
263
- },
264
- findMany: async ({ model, where, sortBy, limit, select, offset, join }) => {
265
- const res = convertWhereClause(where || [], model, join, select);
266
- if (join) {
267
- const resArray = res;
268
- if (!resArray.length) return [];
269
- applySortToRecords(resArray, sortBy, model);
270
- let paginatedRecords = resArray;
271
- if (offset !== void 0) paginatedRecords = paginatedRecords.slice(offset);
272
- if (limit !== void 0) paginatedRecords = paginatedRecords.slice(0, limit);
273
- return paginatedRecords;
274
- }
275
- let table = applySortToRecords(res, sortBy, model);
276
- if (offset !== void 0) table = table.slice(offset);
277
- if (limit !== void 0) table = table.slice(0, limit);
278
- return table || [];
279
- },
280
- count: async ({ model, where }) => {
281
- if (where) return convertWhereClause(where, model).length;
282
- return activeDb[model].length;
283
- },
284
- update: async ({ model, where, update }) => {
285
- if (where.length === 0) return null;
286
- const res = convertWhereClause(where, model);
287
- res.forEach((record) => {
288
- Object.assign(record, update);
289
- });
290
- return res[0] || null;
291
- },
292
- delete: async ({ model, where }) => {
293
- if (where.length === 0) return;
294
- const table = activeDb[model];
295
- const res = convertWhereClause(where, model);
296
- activeDb[model] = table.filter((record) => !res.includes(record));
297
- },
298
- deleteMany: async ({ model, where }) => {
299
- const table = activeDb[model];
300
- const res = convertWhereClause(where, model);
301
- let count = 0;
302
- activeDb[model] = table.filter((record) => {
303
- if (res.includes(record)) {
304
- count++;
305
- return false;
306
- }
307
- return !res.includes(record);
308
- });
309
- return count;
310
- },
311
- consumeOne: async ({ model, where }) => {
312
- const table = activeDb[model];
313
- const target = convertWhereClause(where, model)[0];
314
- if (!target) return null;
315
- activeDb[model] = table.filter((record) => record !== target);
316
- return target;
317
- },
318
- incrementOne: async ({ model, where, increment, set }) => {
319
- const target = convertWhereClause(where, model)[0];
320
- if (!target) return null;
321
- for (const [field, delta] of Object.entries(increment)) target[field] = (typeof target[field] === "number" ? target[field] : 0) + delta;
322
- if (set) Object.assign(target, set);
323
- return target;
324
- },
325
- updateMany: async ({ model, where, update }) => {
326
- const res = convertWhereClause(where, model);
327
- res.forEach((record) => {
328
- Object.assign(record, update);
329
- });
330
- return res.length;
331
- }
332
- };
333
- }
334
- });
335
- const adapterCreator = buildAdapterFactory(db);
336
- return (options) => {
337
- lazyOptions = options;
338
- return adapterCreator(options);
339
- };
340
- };
341
- //#endregion
342
- export { memoryAdapter };