kindstore 0.1.3 → 0.1.4
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/README.md +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -71,6 +71,7 @@ type ConnectionConfig = {
|
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/kind.d.ts
|
|
73
73
|
type MultiIndexFields<T extends KindDefinitionBag> = { [K in keyof KindValue<T> & string]?: IndexDirection };
|
|
74
|
+
type DefaultManagedTimestampField<T extends KindDefinitionBag, TName extends "createdAt" | "updatedAt"> = Extract<TName, keyof KindValue<T> & string>;
|
|
74
75
|
type IndexDefinition = {
|
|
75
76
|
field: string;
|
|
76
77
|
type?: SqliteTypeHint;
|
|
@@ -95,10 +96,10 @@ declare class KindDefinition<T extends KindDefinitionBag> {
|
|
|
95
96
|
}): KindDefinition<Omit<T, "indexed"> & {
|
|
96
97
|
indexed: T["indexed"] | TKey;
|
|
97
98
|
}>;
|
|
98
|
-
createdAt<TKey extends keyof KindValue<T> & string>
|
|
99
|
+
createdAt<TKey extends keyof KindValue<T> & string = DefaultManagedTimestampField<T, "createdAt">>(...args: DefaultManagedTimestampField<T, "createdAt"> extends never ? [field: keyof KindValue<T> & string] : [field?: TKey]): KindDefinition<Omit<T, "createdAt"> & {
|
|
99
100
|
createdAt: TKey;
|
|
100
101
|
}>;
|
|
101
|
-
updatedAt<TKey extends keyof KindValue<T> & string>
|
|
102
|
+
updatedAt<TKey extends keyof KindValue<T> & string = DefaultManagedTimestampField<T, "updatedAt">>(...args: DefaultManagedTimestampField<T, "updatedAt"> extends never ? [field: keyof KindValue<T> & string] : [field?: TKey]): KindDefinition<Omit<T, "updatedAt"> & {
|
|
102
103
|
updatedAt: TKey;
|
|
103
104
|
}>;
|
|
104
105
|
multi<const TName extends string, const TFields extends MultiIndexFields<T> & Record<string, IndexDirection>>(name: TName, fields: TFields): KindDefinition<Omit<T, "indexed"> & {
|
package/dist/index.mjs
CHANGED
|
@@ -24,12 +24,14 @@ var KindDefinition = class {
|
|
|
24
24
|
});
|
|
25
25
|
return this;
|
|
26
26
|
}
|
|
27
|
-
createdAt(
|
|
27
|
+
createdAt(...args) {
|
|
28
|
+
const field = args[0] ?? "createdAt";
|
|
28
29
|
if (field === this.updatedAtField) throw new Error(`Kind "${this.tag}" cannot use "${field}" for both createdAt and updatedAt.`);
|
|
29
30
|
this.createdAtField = field;
|
|
30
31
|
return this;
|
|
31
32
|
}
|
|
32
|
-
updatedAt(
|
|
33
|
+
updatedAt(...args) {
|
|
34
|
+
const field = args[0] ?? "updatedAt";
|
|
33
35
|
if (field === this.createdAtField) throw new Error(`Kind "${this.tag}" cannot use "${field}" for both createdAt and updatedAt.`);
|
|
34
36
|
this.updatedAtField = field;
|
|
35
37
|
return this;
|
package/package.json
CHANGED