imodel 0.19.0 → 0.19.1
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/index.d.mts +90 -3
- package/index.mjs +112 -2
- package/migrate.d.mts +1 -1
- package/migrate.mjs +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.19.
|
|
2
|
+
* imodel v0.19.1
|
|
3
3
|
* (c) 2019-2026 undefined
|
|
4
4
|
* @license undefined
|
|
5
5
|
*/
|
|
@@ -620,6 +620,7 @@ interface Hook<T extends Hooks[keyof Hooks]> {
|
|
|
620
620
|
*/
|
|
621
621
|
declare function toNot(items?: WhereValue[] | null): WhereValue[] | null;
|
|
622
622
|
type WhereItem = {
|
|
623
|
+
exists?: false | null | undefined;
|
|
623
624
|
where?: null | undefined;
|
|
624
625
|
or?: null | undefined;
|
|
625
626
|
field: string | {
|
|
@@ -634,7 +635,16 @@ type WhereItem = {
|
|
|
634
635
|
not?: boolean | undefined;
|
|
635
636
|
operator?: string | null | undefined;
|
|
636
637
|
};
|
|
638
|
+
type WhereExists = {
|
|
639
|
+
where?: null | undefined;
|
|
640
|
+
or?: null | undefined;
|
|
641
|
+
field?: null | undefined;
|
|
642
|
+
exists: true;
|
|
643
|
+
subquery: SelectItem[];
|
|
644
|
+
not?: boolean | undefined;
|
|
645
|
+
};
|
|
637
646
|
type WhereRaw = {
|
|
647
|
+
exists?: false | null | undefined;
|
|
638
648
|
field?: null | undefined;
|
|
639
649
|
or?: null | undefined;
|
|
640
650
|
where: readonly string[];
|
|
@@ -642,12 +652,13 @@ type WhereRaw = {
|
|
|
642
652
|
not?: boolean | undefined;
|
|
643
653
|
};
|
|
644
654
|
type WhereOr = {
|
|
655
|
+
exists?: false | null | undefined;
|
|
645
656
|
where?: null | undefined;
|
|
646
657
|
field?: null | undefined;
|
|
647
658
|
or: WhereValue[][];
|
|
648
659
|
not?: boolean | undefined;
|
|
649
660
|
};
|
|
650
|
-
type WhereValue = WhereItem | WhereRaw | WhereOr;
|
|
661
|
+
type WhereValue = WhereItem | WhereExists | WhereRaw | WhereOr;
|
|
651
662
|
type WhereLike = {
|
|
652
663
|
toWhereValue(): WhereValue[][];
|
|
653
664
|
};
|
|
@@ -738,6 +749,58 @@ declare class Where {
|
|
|
738
749
|
* @returns {Where}
|
|
739
750
|
*/
|
|
740
751
|
static and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
752
|
+
/**
|
|
753
|
+
* @overload
|
|
754
|
+
* @param {Wheres} matches
|
|
755
|
+
* @returns {Where}
|
|
756
|
+
*/
|
|
757
|
+
static where(matches: Wheres): Where;
|
|
758
|
+
/**
|
|
759
|
+
*
|
|
760
|
+
* @overload
|
|
761
|
+
* @param {TemplateStringsArray} where
|
|
762
|
+
* @param {...any} values
|
|
763
|
+
* @returns {Where}
|
|
764
|
+
*/
|
|
765
|
+
static where(where: TemplateStringsArray, ...values: any[]): Where;
|
|
766
|
+
/**
|
|
767
|
+
* @overload
|
|
768
|
+
* @param {string} field
|
|
769
|
+
* @param {any} value
|
|
770
|
+
* @returns {Where}
|
|
771
|
+
*/
|
|
772
|
+
static where(field: string, value: any): Where;
|
|
773
|
+
/**
|
|
774
|
+
* @overload
|
|
775
|
+
* @param {string[]} field
|
|
776
|
+
* @param {any[]} value
|
|
777
|
+
* @returns {Where}
|
|
778
|
+
*/
|
|
779
|
+
static where(field: string[], value: any[]): Where;
|
|
780
|
+
/**
|
|
781
|
+
* @overload
|
|
782
|
+
* @param {string} field
|
|
783
|
+
* @param {string} operator
|
|
784
|
+
* @param {any} value
|
|
785
|
+
* @param {boolean} [not]
|
|
786
|
+
* @returns {Where}
|
|
787
|
+
*/
|
|
788
|
+
static where(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
789
|
+
/**
|
|
790
|
+
* @overload
|
|
791
|
+
* @param {string[]} field
|
|
792
|
+
* @param {string} operator
|
|
793
|
+
* @param {any[]} value
|
|
794
|
+
* @param {boolean} [not]
|
|
795
|
+
* @returns {Where}
|
|
796
|
+
*/
|
|
797
|
+
static where(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
798
|
+
/**
|
|
799
|
+
* @overload
|
|
800
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
801
|
+
* @returns {Where}
|
|
802
|
+
*/
|
|
803
|
+
static where(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
741
804
|
/**
|
|
742
805
|
* @overload
|
|
743
806
|
* @param {Wheres} matches
|
|
@@ -894,6 +957,18 @@ declare class Where {
|
|
|
894
957
|
* @returns {Where}
|
|
895
958
|
*/
|
|
896
959
|
static orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
960
|
+
/**
|
|
961
|
+
*
|
|
962
|
+
* @param {...SelectItem} subquery
|
|
963
|
+
* @returns {Where}
|
|
964
|
+
*/
|
|
965
|
+
static exists(...subquery: SelectItem[]): Where;
|
|
966
|
+
/**
|
|
967
|
+
*
|
|
968
|
+
* @param {...SelectItem} subquery
|
|
969
|
+
* @returns {Where}
|
|
970
|
+
*/
|
|
971
|
+
static notExists(...subquery: SelectItem[]): Where;
|
|
897
972
|
toWhereValue(): WhereValue[][];
|
|
898
973
|
/**
|
|
899
974
|
* @overload
|
|
@@ -1103,6 +1178,18 @@ declare class Where {
|
|
|
1103
1178
|
* @returns {this}
|
|
1104
1179
|
*/
|
|
1105
1180
|
orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1181
|
+
/**
|
|
1182
|
+
*
|
|
1183
|
+
* @param {...SelectItem} subquery
|
|
1184
|
+
* @returns {this}
|
|
1185
|
+
*/
|
|
1186
|
+
exists(...subquery: SelectItem[]): this;
|
|
1187
|
+
/**
|
|
1188
|
+
*
|
|
1189
|
+
* @param {...SelectItem} subquery
|
|
1190
|
+
* @returns {this}
|
|
1191
|
+
*/
|
|
1192
|
+
notExists(...subquery: SelectItem[]): this;
|
|
1106
1193
|
#private;
|
|
1107
1194
|
}
|
|
1108
1195
|
|
|
@@ -2587,4 +2674,4 @@ declare function toBool(v: any): boolean;
|
|
|
2587
2674
|
declare function setDevelopment(d?: boolean): void;
|
|
2588
2675
|
declare let isDevelopment: boolean;
|
|
2589
2676
|
|
|
2590
|
-
export { Build, type ClassDecorator, type Column, type ColumnOptions, Connection, type Constraint, Create, type DBColumn, type DBIndex, type DBTable, Destroy, type Environment, type FieldDecorator, type FieldDefine, type FieldDefineOption, type FieldDefineType, type FieldSpecific, type FieldSpecificValue, type FieldType, type FieldTypeDefine, type FieldValue, type Fields, type FindArg, type FindRange, type GetName, type Hook, type Hooks, type IConnection, type Index, type IndexInfo, type IndexOptions, type JOIN, type Join, type JoinType, type MainFieldType, type MaybePromise, type MethodDecorator, Model, type Options, PseudoDestroy, Query, type QueryOptions, type Queryable, Save, Scene, Select, type SelectItem, SetValue, type Skip, Submodel, type Support, type TableConnect, type TableConnection, type TableDefine, type TableType, type TableValue, type ToFieldType, type ToType, type TransactionFn, type VirtualTable, Where, type WhereItem, type WhereLike, type WhereOr, type WhereRaw, type WhereValue, type Wheres, afterCreate, afterCreateMany, afterDelete, afterUpdate, beforeCreate, beforeCreateMany, beforeDelete, beforeUpdate, bindHooks, coefficient, column, creating, decrement, defaultValue, field as define, deleted, deleting, divide, field$1 as field, getPrimaryFields, getPrimaryKeys, hooks, immutable, increment, index, isDevelopment, isPseudo, mergeHooks, model, multiply, now, primary, prop, pseudo, setDevelopment, sort, model as submodel, toBool, toNot, toPrimaries, toPrimary, uncreatable, undeleted, updating, uuid, values, where, withDeleted };
|
|
2677
|
+
export { Build, type ClassDecorator, type Column, type ColumnOptions, Connection, type Constraint, Create, type DBColumn, type DBIndex, type DBTable, Destroy, type Environment, type FieldDecorator, type FieldDefine, type FieldDefineOption, type FieldDefineType, type FieldSpecific, type FieldSpecificValue, type FieldType, type FieldTypeDefine, type FieldValue, type Fields, type FindArg, type FindRange, type GetName, type Hook, type Hooks, type IConnection, type Index, type IndexInfo, type IndexOptions, type JOIN, type Join, type JoinType, type MainFieldType, type MaybePromise, type MethodDecorator, Model, type Options, PseudoDestroy, Query, type QueryOptions, type Queryable, Save, Scene, Select, type SelectItem, SetValue, type Skip, Submodel, type Support, type TableConnect, type TableConnection, type TableDefine, type TableType, type TableValue, type ToFieldType, type ToType, type TransactionFn, type VirtualTable, Where, type WhereExists, type WhereItem, type WhereLike, type WhereOr, type WhereRaw, type WhereValue, type Wheres, afterCreate, afterCreateMany, afterDelete, afterUpdate, beforeCreate, beforeCreateMany, beforeDelete, beforeUpdate, bindHooks, coefficient, column, creating, decrement, defaultValue, field as define, deleted, deleting, divide, field$1 as field, getPrimaryFields, getPrimaryKeys, hooks, immutable, increment, index, isDevelopment, isPseudo, mergeHooks, model, multiply, now, primary, prop, pseudo, setDevelopment, sort, model as submodel, toBool, toNot, toPrimaries, toPrimary, uncreatable, undeleted, updating, uuid, values, where, withDeleted };
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.19.
|
|
2
|
+
* imodel v0.19.1
|
|
3
3
|
* (c) 2019-2026 undefined
|
|
4
4
|
* @license undefined
|
|
5
5
|
*/
|
|
@@ -26,6 +26,7 @@ class Subquery {
|
|
|
26
26
|
/** @typedef {WhereLike | Record<string, any> | (WhereLike | Record<string, any>)[]} Wheres */
|
|
27
27
|
/**
|
|
28
28
|
* @typedef {object} WhereItem
|
|
29
|
+
* @prop {false?} [exists]
|
|
29
30
|
* @prop {null} [where]
|
|
30
31
|
* @prop {null} [or]
|
|
31
32
|
* @prop {string | {table?: string; field: string} | (string | {table?: string; field: string})[]} field
|
|
@@ -34,8 +35,18 @@ class Subquery {
|
|
|
34
35
|
* @prop {boolean} [not]
|
|
35
36
|
* @prop {string?} [operator]
|
|
36
37
|
*/
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {object} WhereExists
|
|
40
|
+
* @prop {null} [where]
|
|
41
|
+
* @prop {null} [or]
|
|
42
|
+
* @prop {null} [field]
|
|
43
|
+
* @prop {true} exists
|
|
44
|
+
* @prop {SelectItem[]} subquery
|
|
45
|
+
* @prop {boolean} [not]
|
|
46
|
+
*/
|
|
37
47
|
/**
|
|
38
48
|
* @typedef {object} WhereRaw
|
|
49
|
+
* @prop {false?} [exists]
|
|
39
50
|
* @prop {null} [field]
|
|
40
51
|
* @prop {null} [or]
|
|
41
52
|
* @prop {readonly string[]} where
|
|
@@ -44,12 +55,13 @@ class Subquery {
|
|
|
44
55
|
*/
|
|
45
56
|
/**
|
|
46
57
|
* @typedef {object} WhereOr
|
|
58
|
+
* @prop {false?} [exists]
|
|
47
59
|
* @prop {null} [where]
|
|
48
60
|
* @prop {null} [field]
|
|
49
61
|
* @prop {WhereValue[][]} or
|
|
50
62
|
* @prop {boolean} [not]
|
|
51
63
|
*/
|
|
52
|
-
/** @typedef {WhereItem | WhereRaw | WhereOr} WhereValue */
|
|
64
|
+
/** @typedef {WhereItem | WhereExists | WhereRaw | WhereOr} WhereValue */
|
|
53
65
|
/**
|
|
54
66
|
*
|
|
55
67
|
* @param {*} v
|
|
@@ -317,6 +329,58 @@ class Where {
|
|
|
317
329
|
static and(...items) {
|
|
318
330
|
return new Where().#and(parse(items));
|
|
319
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* @overload
|
|
334
|
+
* @param {Wheres} matches
|
|
335
|
+
* @returns {Where}
|
|
336
|
+
*/
|
|
337
|
+
/**
|
|
338
|
+
*
|
|
339
|
+
* @overload
|
|
340
|
+
* @param {TemplateStringsArray} where
|
|
341
|
+
* @param {...any} values
|
|
342
|
+
* @returns {Where}
|
|
343
|
+
*/
|
|
344
|
+
/**
|
|
345
|
+
* @overload
|
|
346
|
+
* @param {string} field
|
|
347
|
+
* @param {any} value
|
|
348
|
+
* @returns {Where}
|
|
349
|
+
*/
|
|
350
|
+
/**
|
|
351
|
+
* @overload
|
|
352
|
+
* @param {string[]} field
|
|
353
|
+
* @param {any[]} value
|
|
354
|
+
* @returns {Where}
|
|
355
|
+
*/
|
|
356
|
+
/**
|
|
357
|
+
* @overload
|
|
358
|
+
* @param {string} field
|
|
359
|
+
* @param {string} operator
|
|
360
|
+
* @param {any} value
|
|
361
|
+
* @param {boolean} [not]
|
|
362
|
+
* @returns {Where}
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* @overload
|
|
366
|
+
* @param {string[]} field
|
|
367
|
+
* @param {string} operator
|
|
368
|
+
* @param {any[]} value
|
|
369
|
+
* @param {boolean} [not]
|
|
370
|
+
* @returns {Where}
|
|
371
|
+
*/
|
|
372
|
+
/**
|
|
373
|
+
* @overload
|
|
374
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
375
|
+
* @returns {Where}
|
|
376
|
+
*/
|
|
377
|
+
/**
|
|
378
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
379
|
+
* @returns {Where}
|
|
380
|
+
*/
|
|
381
|
+
static where(...items) {
|
|
382
|
+
return new Where().#and(parse(items));
|
|
383
|
+
}
|
|
320
384
|
/**
|
|
321
385
|
* @overload
|
|
322
386
|
* @param {Wheres} matches
|
|
@@ -629,6 +693,52 @@ class Where {
|
|
|
629
693
|
static orNot(...items) {
|
|
630
694
|
return new Where().#or(toNot(parse(items)));
|
|
631
695
|
}
|
|
696
|
+
/**
|
|
697
|
+
*
|
|
698
|
+
* @param {...SelectItem} subquery
|
|
699
|
+
* @returns {this}
|
|
700
|
+
*/
|
|
701
|
+
exists(...subquery) {
|
|
702
|
+
return this.#and([{
|
|
703
|
+
exists: true,
|
|
704
|
+
subquery
|
|
705
|
+
}]);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
*
|
|
709
|
+
* @param {...SelectItem} subquery
|
|
710
|
+
* @returns {Where}
|
|
711
|
+
*/
|
|
712
|
+
static exists(...subquery) {
|
|
713
|
+
return new Where().#and([{
|
|
714
|
+
exists: true,
|
|
715
|
+
subquery
|
|
716
|
+
}]);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
*
|
|
720
|
+
* @param {...SelectItem} subquery
|
|
721
|
+
* @returns {this}
|
|
722
|
+
*/
|
|
723
|
+
notExists(...subquery) {
|
|
724
|
+
return this.#and([{
|
|
725
|
+
exists: true,
|
|
726
|
+
subquery,
|
|
727
|
+
not: true
|
|
728
|
+
}]);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
*
|
|
732
|
+
* @param {...SelectItem} subquery
|
|
733
|
+
* @returns {Where}
|
|
734
|
+
*/
|
|
735
|
+
static notExists(...subquery) {
|
|
736
|
+
return new Where().#and([{
|
|
737
|
+
exists: true,
|
|
738
|
+
subquery,
|
|
739
|
+
not: true
|
|
740
|
+
}]);
|
|
741
|
+
}
|
|
632
742
|
}
|
|
633
743
|
|
|
634
744
|
const deleted = Symbol();
|
package/migrate.d.mts
CHANGED
package/migrate.mjs
CHANGED