akanjs 3.1.1-rc.2 → 3.1.1-rc.3

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.
@@ -3,7 +3,7 @@ import type { Logger } from "akanjs/common";
3
3
  import type { DocumentModel, QueryOf } from "akanjs/constant";
4
4
  import type { CacheAdaptor, CacheSetOptions, CacheValue } from "akanjs/service";
5
5
  import type { DataLoader } from "./dataLoader";
6
- import type { DocumentUpdateInput } from "./documentQuery";
6
+ import type { DocumentTouchOptions, DocumentUpdateInput } from "./documentQuery";
7
7
  import type { ExtractQuery, ExtractSort, FilterInstance } from "./filterMeta";
8
8
  import type { Mdl, SaveEventListener, SaveEventType, UpdateResult } from "./into";
9
9
  import type { DataInputOf, FindQueryOption, ListQueryOption } from "./types";
@@ -61,7 +61,7 @@ export class CacheDatabase<_T = unknown> {
61
61
  }
62
62
  /** What `update<Filter>` returns: the patch cannot trail a filter's optional args, so it lands on `.set()`. */
63
63
  export interface UpdateChain<Doc = any> {
64
- set(update: DocumentUpdateInput<Doc>): Promise<UpdateResult>;
64
+ set(update: DocumentUpdateInput<Doc>, options?: DocumentTouchOptions): Promise<UpdateResult>;
65
65
  }
66
66
 
67
67
  type QueryMethodOfKey<
@@ -157,8 +157,16 @@ export type DatabaseInstanceWithQuerySort<
157
157
  __removeMany: (query: _QueryOfDoc) => Promise<UpdateResult>;
158
158
  __removeOne: (query: _QueryOfDoc) => Promise<UpdateResult>;
159
159
  __purgeMany: (query: _QueryOfDoc) => Promise<number>;
160
- __updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
161
- __updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
160
+ __updateMany: (
161
+ query: _QueryOfDoc,
162
+ update: DocumentUpdateInput<Doc>,
163
+ options?: DocumentTouchOptions,
164
+ ) => Promise<UpdateResult>;
165
+ __updateOne: (
166
+ query: _QueryOfDoc,
167
+ update: DocumentUpdateInput<Doc>,
168
+ options?: DocumentTouchOptions,
169
+ ) => Promise<UpdateResult>;
162
170
  __list(query: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<Doc[]>;
163
171
  __listIds(query: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<string[]>;
164
172
  __find(query: _QueryOfDoc, queryOption?: _FindQueryOption): Promise<Doc | null>;
@@ -106,7 +106,12 @@ export interface DocumentScopeOptions {
106
106
  withRemoved?: boolean;
107
107
  }
108
108
 
109
- export interface DocumentUpdateOptions extends DocumentScopeOptions {
109
+ export interface DocumentTouchOptions {
110
+ /** `false` leaves `updatedAt` as stored, for bookkeeping that is no edit: a lease heartbeat, a mirrored snapshot. */
111
+ touch?: boolean;
112
+ }
113
+
114
+ export interface DocumentUpdateOptions extends DocumentScopeOptions, DocumentTouchOptions {
110
115
  upsert?: boolean;
111
116
  }
112
117
 
package/document/into.ts CHANGED
@@ -4,7 +4,13 @@ import type { DocumentModel, QueryOf } from "akanjs/constant";
4
4
  import type { FilterCls, FilterQueryOf, FilterSortOf, SchemaOf } from ".";
5
5
  import type { CacheDatabase, QueryMethodPart } from "./database";
6
6
  import type { DataLoader } from "./dataLoader";
7
- import type { DocumentQuery, DocumentScopeOptions, DocumentUpdateInput, DocumentUpdateOptions } from "./documentQuery";
7
+ import type {
8
+ DocumentQuery,
9
+ DocumentScopeOptions,
10
+ DocumentTouchOptions,
11
+ DocumentUpdateInput,
12
+ DocumentUpdateOptions,
13
+ } from "./documentQuery";
8
14
  import { type LoaderBuilder, type ModelCls, makeLoaderBuilder } from "./loaderInfo";
9
15
  import type { DocumentProjection } from "./types";
10
16
 
@@ -79,7 +85,7 @@ export type Mdl<
79
85
  updateMany(
80
86
  query: _RawQuery,
81
87
  update: DocumentUpdateInput<_RawDoc>,
82
- options?: DocumentScopeOptions,
88
+ options?: DocumentScopeOptions & DocumentTouchOptions,
83
89
  ): Promise<UpdateResult>;
84
90
  removeOne(query: _RawQuery): Promise<UpdateResult>;
85
91
  removeMany(query: _RawQuery): Promise<UpdateResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.1.1-rc.2",
3
+ "version": "3.1.1-rc.3",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,4 +1,4 @@
1
- import { type BackendEnv, DatabaseModes, getEnv } from "akanjs/base";
1
+ import { type BackendEnv, DatabaseModes, getEnv, INTERNAL_META } from "akanjs/base";
2
2
  import { Logger } from "akanjs/common";
3
3
  import { ConstantRegistry } from "akanjs/constant";
4
4
  import {
@@ -195,6 +195,7 @@ export class DiLifecycle {
195
195
  this.logger.info("agent relay is provided by a lib module — the framework's is skipped");
196
196
  if (!this.#scalar.has("agentTurn"))
197
197
  this.#scalar.set("agentTurn", { constant: agentTurnConstant, database: agentTurnDocument });
198
+ this.#assertUniqueInternalJobs();
198
199
  const adaptorClaims = new Map<string, AdaptorCls>();
199
200
  const adaptorRegistrations: Registration[] = [];
200
201
  const claimAdaptor = (adaptorCls: AdaptorCls, owner: string) => {
@@ -460,6 +461,15 @@ export class DiLifecycle {
460
461
  this.logger.verbose(`${doneLabel} in ${Date.now() - now}ms`);
461
462
  }
462
463
 
464
+ #assertUniqueInternalJobs() {
465
+ const jobs = this.#allModules().flatMap(({ signal: { internal } }) =>
466
+ Object.entries(internal[INTERNAL_META])
467
+ .filter(([, { type }]) => type !== "resolveField")
468
+ .map(([key, { type }]) => ({ key, owner: `the ${type} of "${internal.refName}"` })),
469
+ );
470
+ assertUniqueRegistrations("internal", jobs);
471
+ }
472
+
463
473
  registerSchedule(serverMode: "federation" | "batch" | "all") {
464
474
  const internals = this.#allModules().map((mod) => mod.signal.internal);
465
475
  const failures: { label: string; reason: unknown }[] = [];
@@ -11,6 +11,7 @@ import {
11
11
  DataLoader,
12
12
  DocumentSchema,
13
13
  type DocumentScopeOptions,
14
+ type DocumentTouchOptions,
14
15
  type DocumentUpdateInput,
15
16
  type DocumentUpdateOptions,
16
17
  documentQueryHelper,
@@ -45,6 +46,9 @@ const timedQuery = async <T>(fn: () => Promise<T>): Promise<T> => {
45
46
  trace.countDbQuery(performance.now() - start);
46
47
  }
47
48
  };
49
+ const touchOf = (options?: DocumentTouchOptions) => (options?.touch === false ? { touch: false } : {});
50
+ const touchArgs = (options?: DocumentTouchOptions): [] | [DocumentTouchOptions] =>
51
+ options?.touch === false ? [{ touch: false }] : [];
48
52
 
49
53
  export class DatabaseResolver {
50
54
 
@@ -205,6 +209,12 @@ export class DatabaseResolver {
205
209
  const scopeOf = (options?: DocumentScopeOptions) => (options?.withRemoved ? { withRemoved: true } : {});
206
210
  const scopeArgs = (options?: DocumentScopeOptions): [] | [DocumentScopeOptions] =>
207
211
  options?.withRemoved ? [{ withRemoved: true }] : [];
212
+ const updateManyArgs = (
213
+ options?: DocumentScopeOptions & DocumentTouchOptions,
214
+ ): [] | [DocumentScopeOptions & DocumentTouchOptions] => {
215
+ const narrowed = { ...scopeOf(options), ...touchOf(options) };
216
+ return Object.keys(narrowed).length ? [narrowed] : [];
217
+ };
208
218
  const createFindManyChain = (
209
219
  query: QueryOf<any>,
210
220
  options: { sort?: any; skip?: number; limit?: number; select?: any; withRemoved?: boolean } = {},
@@ -287,8 +297,11 @@ export class DatabaseResolver {
287
297
  timedQuery(() => store.count(query, ...scopeArgs(options))),
288
298
  updateOne: (query: QueryOf<any>, update: DocumentUpdateInput, options?: DocumentUpdateOptions) =>
289
299
  timedQuery(() => store.updateOneByQuery(query, update, options)),
290
- updateMany: (query: QueryOf<any>, update: DocumentUpdateInput, options?: DocumentScopeOptions) =>
291
- timedQuery(() => store.updateManyByQuery(query, update, ...scopeArgs(options))),
300
+ updateMany: (
301
+ query: QueryOf<any>,
302
+ update: DocumentUpdateInput,
303
+ options?: DocumentScopeOptions & DocumentTouchOptions,
304
+ ) => timedQuery(() => store.updateManyByQuery(query, update, ...updateManyArgs(options))),
292
305
  removeOne: (query: QueryOf<any>) => timedQuery(() => store.removeOneByQuery(query)),
293
306
  removeMany: (query: QueryOf<any>) => timedQuery(() => store.removeManyByQuery(query)),
294
307
  purgeMany: (query: QueryOf<any>) => timedQuery(() => store.purgeManyByQuery(query)),
@@ -401,11 +414,11 @@ export class DatabaseResolver {
401
414
  async __purgeMany(query: QueryOf<any>) {
402
415
  return await timedQuery(() => this.__store.purgeManyByQuery(query));
403
416
  }
404
- async __updateMany(query: QueryOf<any>, update: DocumentUpdateInput) {
405
- return await timedQuery(() => this.__store.updateManyByQuery(query, update));
417
+ async __updateMany(query: QueryOf<any>, update: DocumentUpdateInput, options?: DocumentTouchOptions) {
418
+ return await timedQuery(() => this.__store.updateManyByQuery(query, update, ...touchArgs(options)));
406
419
  }
407
- async __updateOne(query: QueryOf<any>, update: DocumentUpdateInput) {
408
- return await timedQuery(() => this.__store.updateOneByQuery(query, update));
420
+ async __updateOne(query: QueryOf<any>, update: DocumentUpdateInput, options?: DocumentTouchOptions) {
421
+ return await timedQuery(() => this.__store.updateOneByQuery(query, update, ...touchArgs(options)));
409
422
  }
410
423
  async [`remove${className}`](id: string) {
411
424
  return this.__remove(id);
@@ -1,6 +1,6 @@
1
1
  import { capitalize } from "akanjs/common";
2
2
  import type { QueryOf } from "akanjs/constant";
3
- import type { DatabaseModel, DataInputOf, Doc, DocumentUpdateInput } from "akanjs/document";
3
+ import type { DatabaseModel, DataInputOf, Doc, DocumentTouchOptions, DocumentUpdateInput } from "akanjs/document";
4
4
  import { type DatabaseService, type ServiceCls, ServiceModel } from "akanjs/service";
5
5
  import type { CascadeRunner } from "./CascadeRunner";
6
6
  import { DatabaseResolver } from "./database.resolver";
@@ -38,11 +38,19 @@ export class ServiceResolver {
38
38
  async __purgeMany(this: DatabaseService, query: QueryOf<any>) {
39
39
  return await this.__databaseModel.__purgeMany(query);
40
40
  },
41
- async __updateMany(this: DatabaseService, query: QueryOf<any>, update: DocumentUpdateInput) {
42
- return await this.__databaseModel.__updateMany(query, update);
43
- },
44
- async __updateOne(this: DatabaseService, query: QueryOf<any>, update: DocumentUpdateInput) {
45
- return await this.__databaseModel.__updateOne(query, update);
41
+ async __updateMany(
42
+ this: DatabaseService,
43
+ query: QueryOf<any>,
44
+ ...set: [DocumentUpdateInput, DocumentTouchOptions?]
45
+ ) {
46
+ return await this.__databaseModel.__updateMany(query, ...set);
47
+ },
48
+ async __updateOne(
49
+ this: DatabaseService,
50
+ query: QueryOf<any>,
51
+ ...set: [DocumentUpdateInput, DocumentTouchOptions?]
52
+ ) {
53
+ return await this.__databaseModel.__updateOne(query, ...set);
46
54
  },
47
55
  };
48
56
  }
@@ -9,6 +9,7 @@ import {
9
9
  type DocumentQuery,
10
10
  type DocumentSchema,
11
11
  type DocumentScopeOptions,
12
+ type DocumentTouchOptions,
12
13
  type DocumentUpdate,
13
14
  type DocumentUpdateInput,
14
15
  type DocumentUpdateNode,
@@ -471,7 +472,7 @@ export class SqlDocumentStore {
471
472
  operation: string,
472
473
  ) {
473
474
  const resolved = resolveDocumentUpdate(update);
474
- const { assignments, params } = this.compiledUpdate(resolved);
475
+ const { assignments, params } = this.compiledUpdate(resolved, options);
475
476
  const { where, params: whereParams } = this.writeQuery(query, operation, options);
476
477
  const subquery = `SELECT ${quoteIdent("id")} FROM ${quoteIdent(this.table)} WHERE ${where} ORDER BY ${this.compiler.orderBy()} LIMIT 1`;
477
478
 
@@ -490,17 +491,21 @@ export class SqlDocumentStore {
490
491
  return { acknowledged: true, matchedCount: 0, modifiedCount: 1, upsertedId: inserted.id };
491
492
  }
492
493
 
493
- async updateManyByQuery(query: DocumentQuery, update: DocumentUpdateInput, options: DocumentScopeOptions = {}) {
494
+ async updateManyByQuery(
495
+ query: DocumentQuery,
496
+ update: DocumentUpdateInput,
497
+ options: DocumentScopeOptions & DocumentTouchOptions = {},
498
+ ) {
494
499
  return await this.#updateMany(query, update, options, "updateManyByQuery");
495
500
  }
496
501
 
497
502
  async #updateMany(
498
503
  query: DocumentQuery,
499
504
  update: DocumentUpdateInput,
500
- options: DocumentScopeOptions,
505
+ options: DocumentScopeOptions & DocumentTouchOptions,
501
506
  operation: string,
502
507
  ) {
503
- const { assignments, params } = this.compiledUpdate(resolveDocumentUpdate(update));
508
+ const { assignments, params } = this.compiledUpdate(resolveDocumentUpdate(update), options);
504
509
  const { where, params: whereParams } = this.writeQuery(query, operation, options);
505
510
  const sql = `UPDATE ${quoteIdent(this.table)} SET ${assignments.join(", ")} WHERE ${where}`;
506
511
  const changes = this.dialect.affectedRows(
@@ -559,14 +564,14 @@ export class SqlDocumentStore {
559
564
  return false;
560
565
  }
561
566
 
562
- private compiledUpdate(update: DocumentUpdate) {
567
+ private compiledUpdate(update: DocumentUpdate, { touch = true }: DocumentTouchOptions = {}) {
563
568
  for (const raw of Object.values(update))
564
569
  assertStorableJson(jsonStr(isDocumentUpdateNode(raw) ? raw.value : raw), this.table);
565
- const compiled = this.updateCompiler.compile(update);
566
- return {
567
- assignments: [`${quoteIdent("updatedAt")} = ?`, ...compiled.assignments],
568
- params: [Date.now(), ...compiled.params],
569
- };
570
+ const { assignments, params } = this.updateCompiler.compile(update);
571
+ const updatedAt = quoteIdent("updatedAt");
572
+ if (touch) return { assignments: [`${updatedAt} = ?`, ...assignments], params: [Date.now(), ...params] };
573
+
574
+ return { assignments: assignments.length ? assignments : [`${updatedAt} = ${updatedAt}`], params };
570
575
  }
571
576
 
572
577
  async bulkWrite(
@@ -6,6 +6,7 @@ import type {
6
6
  DocumentQueryNode,
7
7
  DocumentSchema,
8
8
  DocumentScopeOptions,
9
+ DocumentTouchOptions,
9
10
  DocumentUpdateInput,
10
11
  DocumentUpdateOperator,
11
12
  DocumentUpdateOptions,
@@ -66,7 +67,7 @@ export interface DocumentStore {
66
67
  updateManyByQuery(
67
68
  query: DocumentQuery,
68
69
  update: DocumentUpdateInput,
69
- options?: DocumentScopeOptions,
70
+ options?: DocumentScopeOptions & DocumentTouchOptions,
70
71
  ): Promise<{ acknowledged: boolean; matchedCount: number; modifiedCount: number }>;
71
72
  removeManyByQuery(
72
73
  query: DocumentQuery,
@@ -207,11 +207,11 @@ export class ServiceModel<
207
207
  },
208
208
  [`update${key}`]: function (this: DatabaseService, ...args: any): UpdateChain {
209
209
  const query = queryOf(args);
210
- return { set: (update) => this.__updateMany(query, update) };
210
+ return { set: (...set) => this.__updateMany(query, ...set) };
211
211
  },
212
212
  [`updateOne${key}`]: function (this: DatabaseService, ...args: any): UpdateChain {
213
213
  const query = queryOf(args);
214
- return { set: (update) => this.__updateOne(query, update) };
214
+ return { set: (...set) => this.__updateOne(query, ...set) };
215
215
  },
216
216
  };
217
217
  }
package/service/types.ts CHANGED
@@ -4,6 +4,7 @@ import type { QueryOf } from "akanjs/constant";
4
4
  import type {
5
5
  DatabaseModel,
6
6
  DataInputOf,
7
+ DocumentTouchOptions,
7
8
  DocumentUpdateInput,
8
9
  FilterInstance,
9
10
  FindQueryOption,
@@ -106,8 +107,16 @@ export type DatabaseService<
106
107
  __removeMany: (query: _QueryOfDoc) => Promise<UpdateResult>;
107
108
  __removeOne: (query: _QueryOfDoc) => Promise<UpdateResult>;
108
109
  __purgeMany: (query: _QueryOfDoc) => Promise<number>;
109
- __updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
110
- __updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
110
+ __updateMany: (
111
+ query: _QueryOfDoc,
112
+ update: DocumentUpdateInput<Doc>,
113
+ options?: DocumentTouchOptions,
114
+ ) => Promise<UpdateResult>;
115
+ __updateOne: (
116
+ query: _QueryOfDoc,
117
+ update: DocumentUpdateInput<Doc>,
118
+ options?: DocumentTouchOptions,
119
+ ) => Promise<UpdateResult>;
111
120
  __list(query?: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<Doc[]>;
112
121
  __listIds(query?: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<string[]>;
113
122
  __find(query?: _QueryOfDoc, queryOption?: _FindQueryOption): Promise<Doc | null>;
@@ -3,7 +3,7 @@ import type { Logger } from "akanjs/common";
3
3
  import type { DocumentModel, QueryOf } from "akanjs/constant";
4
4
  import type { CacheAdaptor, CacheSetOptions, CacheValue } from "akanjs/service";
5
5
  import type { DataLoader } from "./dataLoader.d.ts";
6
- import type { DocumentUpdateInput } from "./documentQuery.d.ts";
6
+ import type { DocumentTouchOptions, DocumentUpdateInput } from "./documentQuery.d.ts";
7
7
  import type { ExtractQuery, ExtractSort, FilterInstance } from "./filterMeta.d.ts";
8
8
  import type { Mdl, SaveEventListener, SaveEventType, UpdateResult } from "./into.d.ts";
9
9
  import type { DataInputOf, FindQueryOption, ListQueryOption } from "./types.d.ts";
@@ -29,7 +29,7 @@ export declare class CacheDatabase<_T = unknown> {
29
29
  }
30
30
  /** What `update<Filter>` returns: the patch cannot trail a filter's optional args, so it lands on `.set()`. */
31
31
  export interface UpdateChain<Doc = any> {
32
- set(update: DocumentUpdateInput<Doc>): Promise<UpdateResult>;
32
+ set(update: DocumentUpdateInput<Doc>, options?: DocumentTouchOptions): Promise<UpdateResult>;
33
33
  }
34
34
  type QueryMethodOfKey<CapitalizedK extends string, Doc, Insight, _Args extends any[], _ListArgs extends any[], _FindArgs extends any[], _QueryOfDoc = QueryOf<Doc>> = {
35
35
  [K in `list${CapitalizedK}`]: (...args: _ListArgs) => Promise<Doc[]>;
@@ -86,8 +86,8 @@ export type DatabaseInstanceWithQuerySort<T extends string = string, Input = any
86
86
  __removeMany: (query: _QueryOfDoc) => Promise<UpdateResult>;
87
87
  __removeOne: (query: _QueryOfDoc) => Promise<UpdateResult>;
88
88
  __purgeMany: (query: _QueryOfDoc) => Promise<number>;
89
- __updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
90
- __updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
89
+ __updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>, options?: DocumentTouchOptions) => Promise<UpdateResult>;
90
+ __updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>, options?: DocumentTouchOptions) => Promise<UpdateResult>;
91
91
  __list(query: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<Doc[]>;
92
92
  __listIds(query: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<string[]>;
93
93
  __find(query: _QueryOfDoc, queryOption?: _FindQueryOption): Promise<Doc | null>;
@@ -55,7 +55,11 @@ export type DocumentUpdate<T = any> = {
55
55
  export interface DocumentScopeOptions {
56
56
  withRemoved?: boolean;
57
57
  }
58
- export interface DocumentUpdateOptions extends DocumentScopeOptions {
58
+ export interface DocumentTouchOptions {
59
+ /** `false` leaves `updatedAt` as stored, for bookkeeping that is no edit: a lease heartbeat, a mirrored snapshot. */
60
+ touch?: boolean;
61
+ }
62
+ export interface DocumentUpdateOptions extends DocumentScopeOptions, DocumentTouchOptions {
59
63
  upsert?: boolean;
60
64
  }
61
65
  export declare const createDocumentUpdateHelper: () => {
@@ -3,7 +3,7 @@ import type { DocumentModel, QueryOf } from "akanjs/constant";
3
3
  import type { FilterCls, FilterQueryOf, FilterSortOf } from ".";
4
4
  import type { CacheDatabase, QueryMethodPart } from "./database.d.ts";
5
5
  import type { DataLoader } from "./dataLoader.d.ts";
6
- import type { DocumentQuery, DocumentScopeOptions, DocumentUpdateInput, DocumentUpdateOptions } from "./documentQuery.d.ts";
6
+ import type { DocumentQuery, DocumentScopeOptions, DocumentTouchOptions, DocumentUpdateInput, DocumentUpdateOptions } from "./documentQuery.d.ts";
7
7
  import { type LoaderBuilder, type ModelCls } from "./loaderInfo.d.ts";
8
8
  import type { DocumentProjection } from "./types.d.ts";
9
9
  export type CRUDEventType = "create" | "update" | "remove";
@@ -52,7 +52,7 @@ export type Mdl<Doc, Raw, _RawDoc = DocumentModel<Raw>, _RawQuery extends Docume
52
52
  count(query: _RawQuery, options?: DocumentScopeOptions): Promise<number>;
53
53
  exists(query: _RawQuery, options?: DocumentScopeOptions): Promise<string | null>;
54
54
  updateOne(query: _RawQuery, update: DocumentUpdateInput<_RawDoc>, options?: DocumentUpdateOptions): Promise<UpdateResult>;
55
- updateMany(query: _RawQuery, update: DocumentUpdateInput<_RawDoc>, options?: DocumentScopeOptions): Promise<UpdateResult>;
55
+ updateMany(query: _RawQuery, update: DocumentUpdateInput<_RawDoc>, options?: DocumentScopeOptions & DocumentTouchOptions): Promise<UpdateResult>;
56
56
  removeOne(query: _RawQuery): Promise<UpdateResult>;
57
57
  removeMany(query: _RawQuery): Promise<UpdateResult>;
58
58
  /** Deletes every row the query matches, removed ones too, and answers how many: no hook, cascade or undo. */
@@ -1,5 +1,5 @@
1
1
  import { type ConstantModel } from "akanjs/constant";
2
- import { type DatabaseModel, type DocumentQuery, type DocumentSchema, type DocumentScopeOptions, type DocumentUpdateInput, type DocumentUpdateOptions } from "akanjs/document";
2
+ import { type DatabaseModel, type DocumentQuery, type DocumentSchema, type DocumentScopeOptions, type DocumentTouchOptions, type DocumentUpdateInput, type DocumentUpdateOptions } from "akanjs/document";
3
3
  import { QueryCompiler } from "./QueryCompiler.d.ts";
4
4
  import { type DocumentDatabaseOwner, type DocumentRecord, type FindIdOptions, type FindManyOptions, type FindOneOptions, type SqlDialect, type TransferRow, type UpsertByIdOptions, type WriteHookOptions } from "./types.d.ts";
5
5
  import { UpdateCompiler } from "./UpdateCompiler.d.ts";
@@ -34,7 +34,7 @@ export declare class SqlDocumentStore {
34
34
  modifiedCount: number;
35
35
  upsertedId: any;
36
36
  }>;
37
- updateManyByQuery(query: DocumentQuery, update: DocumentUpdateInput, options?: DocumentScopeOptions): Promise<{
37
+ updateManyByQuery(query: DocumentQuery, update: DocumentUpdateInput, options?: DocumentScopeOptions & DocumentTouchOptions): Promise<{
38
38
  acknowledged: boolean;
39
39
  matchedCount: number;
40
40
  modifiedCount: number;
@@ -1,6 +1,6 @@
1
1
  import type { PromiseOrObject } from "akanjs/base";
2
2
  import type { ConstantModel } from "akanjs/constant";
3
- import type { DatabaseModel, DocumentQuery, DocumentQueryNode, DocumentSchema, DocumentScopeOptions, DocumentUpdateInput, DocumentUpdateOperator, DocumentUpdateOptions } from "akanjs/document";
3
+ import type { DatabaseModel, DocumentQuery, DocumentQueryNode, DocumentSchema, DocumentScopeOptions, DocumentTouchOptions, DocumentUpdateInput, DocumentUpdateOperator, DocumentUpdateOptions } from "akanjs/document";
4
4
  import type { SearchIndex } from "../searchIndex.d.ts";
5
5
  import type { SqlDocumentStore } from "./SqlDocumentStore.d.ts";
6
6
  export interface SqliteDatabaseConfig {
@@ -52,7 +52,7 @@ export interface DocumentStore {
52
52
  modifiedCount: number;
53
53
  upsertedId: string | null;
54
54
  }>;
55
- updateManyByQuery(query: DocumentQuery, update: DocumentUpdateInput, options?: DocumentScopeOptions): Promise<{
55
+ updateManyByQuery(query: DocumentQuery, update: DocumentUpdateInput, options?: DocumentScopeOptions & DocumentTouchOptions): Promise<{
56
56
  acknowledged: boolean;
57
57
  matchedCount: number;
58
58
  modifiedCount: number;
@@ -1,7 +1,7 @@
1
1
  import type { Cls, MergeAllTypes, PromiseOrObject } from "akanjs/base";
2
2
  import type { Logger } from "akanjs/common";
3
3
  import type { QueryOf } from "akanjs/constant";
4
- import type { DatabaseModel, DataInputOf, DocumentUpdateInput, FilterInstance, FindQueryOption, GetDocObject, ListQueryOption, QueryMethodPart, SaveEventListener, SaveEventType, UpdateResult } from "akanjs/document";
4
+ import type { DatabaseModel, DataInputOf, DocumentTouchOptions, DocumentUpdateInput, FilterInstance, FindQueryOption, GetDocObject, ListQueryOption, QueryMethodPart, SaveEventListener, SaveEventType, UpdateResult } from "akanjs/document";
5
5
  type ServiceMixinOmitKey = "onInit" | "onDestroy" | "_libsOnInit" | "_libsOnDestroy" | "_preCreate" | "_postCreate" | "_preUpdate" | "_postUpdate" | "_preRemove" | "_postRemove" | "_libsPreCreate" | "_libsPostCreate" | "_libsPreUpdate" | "_libsPostUpdate" | "_libsPreRemove" | "_libsPostRemove";
6
6
  type DatabaseQueryMethods<Query, Sort, Obj, Doc, Insight, FindQueryOption, ListQueryOption, DocQuery> = QueryMethodPart<Query, Sort, Obj, Doc, Insight, FindQueryOption, ListQueryOption, DocQuery>;
7
7
  type DocumentLike = {
@@ -34,8 +34,8 @@ export type DatabaseService<T extends string = string, Input = any, Doc = any, O
34
34
  __removeMany: (query: _QueryOfDoc) => Promise<UpdateResult>;
35
35
  __removeOne: (query: _QueryOfDoc) => Promise<UpdateResult>;
36
36
  __purgeMany: (query: _QueryOfDoc) => Promise<number>;
37
- __updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
38
- __updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
37
+ __updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>, options?: DocumentTouchOptions) => Promise<UpdateResult>;
38
+ __updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>, options?: DocumentTouchOptions) => Promise<UpdateResult>;
39
39
  __list(query?: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<Doc[]>;
40
40
  __listIds(query?: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<string[]>;
41
41
  __find(query?: _QueryOfDoc, queryOption?: _FindQueryOption): Promise<Doc | null>;