pinia-orm-edge 1.9.0-28582105.fda0f99 → 1.9.0-28583149.676ad48
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/dist/casts.d.cts +2 -1
- package/dist/casts.d.mts +2 -1
- package/dist/casts.d.ts +2 -1
- package/dist/decorators.d.cts +3 -2
- package/dist/decorators.d.mts +3 -2
- package/dist/decorators.d.ts +3 -2
- package/dist/helpers.d.cts +4 -3
- package/dist/helpers.d.mts +4 -3
- package/dist/helpers.d.ts +4 -3
- package/dist/index.cjs +70 -12
- package/dist/index.d.cts +4 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.mjs +70 -12
- package/dist/nanoid/async.d.cts +2 -1
- package/dist/nanoid/async.d.mts +2 -1
- package/dist/nanoid/async.d.ts +2 -1
- package/dist/nanoid/index.d.cts +2 -1
- package/dist/nanoid/index.d.mts +2 -1
- package/dist/nanoid/index.d.ts +2 -1
- package/dist/nanoid/non-secure.d.cts +2 -1
- package/dist/nanoid/non-secure.d.mts +2 -1
- package/dist/nanoid/non-secure.d.ts +2 -1
- package/dist/shared/{pinia-orm.4d8aa1c7.d.cts → pinia-orm.b86abeaa.d.cts} +97 -71
- package/dist/shared/{pinia-orm.4d8aa1c7.d.mts → pinia-orm.b86abeaa.d.mts} +97 -71
- package/dist/shared/{pinia-orm.4d8aa1c7.d.ts → pinia-orm.b86abeaa.d.ts} +97 -71
- package/dist/uuid/v1.d.cts +2 -1
- package/dist/uuid/v1.d.mts +2 -1
- package/dist/uuid/v1.d.ts +2 -1
- package/dist/uuid/v4.d.cts +2 -1
- package/dist/uuid/v4.d.mts +2 -1
- package/dist/uuid/v4.d.ts +2 -1
- package/package.json +2 -2
package/dist/casts.d.cts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b86abeaa.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class ArrayCast extends CastAttribute {
|
package/dist/casts.d.mts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b86abeaa.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class ArrayCast extends CastAttribute {
|
package/dist/casts.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b86abeaa.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class ArrayCast extends CastAttribute {
|
package/dist/decorators.d.cts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.b86abeaa.cjs';
|
2
|
+
export { aq as NanoidOptions } from './shared/pinia-orm.b86abeaa.cjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/model/Model';
|
5
6
|
import '@/composables';
|
6
7
|
|
7
8
|
/**
|
package/dist/decorators.d.mts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.b86abeaa.mjs';
|
2
|
+
export { aq as NanoidOptions } from './shared/pinia-orm.b86abeaa.mjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/model/Model';
|
5
6
|
import '@/composables';
|
6
7
|
|
7
8
|
/**
|
package/dist/decorators.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.b86abeaa.js';
|
2
|
+
export { aq as NanoidOptions } from './shared/pinia-orm.b86abeaa.js';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/model/Model';
|
5
6
|
import '@/composables';
|
6
7
|
|
7
8
|
/**
|
package/dist/helpers.d.cts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.b86abeaa.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
@@ -24,7 +25,7 @@ declare function useCollect<M extends Model = Model>(models: Collection<M>): Use
|
|
24
25
|
/**
|
25
26
|
* Get the sum value of the specified filed.
|
26
27
|
*/
|
27
|
-
declare function useSum(models: Collection
|
28
|
+
declare function useSum(models: Collection<any>, field: string): number;
|
28
29
|
|
29
30
|
/**
|
30
31
|
* The useGroupBy method groups the collection's items by a given key.
|
@@ -34,7 +35,7 @@ declare function useGroupBy<T extends Record<string, any>>(models: T[], fields:
|
|
34
35
|
/**
|
35
36
|
* The keys method returns all of the collection's primary keys
|
36
37
|
*/
|
37
|
-
declare function useKeys(models: Collection): string[];
|
38
|
+
declare function useKeys(models: Collection<any>): string[];
|
38
39
|
|
39
40
|
/**
|
40
41
|
* Get the min value of the specified filed.
|
package/dist/helpers.d.mts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.b86abeaa.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
@@ -24,7 +25,7 @@ declare function useCollect<M extends Model = Model>(models: Collection<M>): Use
|
|
24
25
|
/**
|
25
26
|
* Get the sum value of the specified filed.
|
26
27
|
*/
|
27
|
-
declare function useSum(models: Collection
|
28
|
+
declare function useSum(models: Collection<any>, field: string): number;
|
28
29
|
|
29
30
|
/**
|
30
31
|
* The useGroupBy method groups the collection's items by a given key.
|
@@ -34,7 +35,7 @@ declare function useGroupBy<T extends Record<string, any>>(models: T[], fields:
|
|
34
35
|
/**
|
35
36
|
* The keys method returns all of the collection's primary keys
|
36
37
|
*/
|
37
|
-
declare function useKeys(models: Collection): string[];
|
38
|
+
declare function useKeys(models: Collection<any>): string[];
|
38
39
|
|
39
40
|
/**
|
40
41
|
* Get the min value of the specified filed.
|
package/dist/helpers.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.b86abeaa.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
@@ -24,7 +25,7 @@ declare function useCollect<M extends Model = Model>(models: Collection<M>): Use
|
|
24
25
|
/**
|
25
26
|
* Get the sum value of the specified filed.
|
26
27
|
*/
|
27
|
-
declare function useSum(models: Collection
|
28
|
+
declare function useSum(models: Collection<any>, field: string): number;
|
28
29
|
|
29
30
|
/**
|
30
31
|
* The useGroupBy method groups the collection's items by a given key.
|
@@ -34,7 +35,7 @@ declare function useGroupBy<T extends Record<string, any>>(models: T[], fields:
|
|
34
35
|
/**
|
35
36
|
* The keys method returns all of the collection's primary keys
|
36
37
|
*/
|
37
|
-
declare function useKeys(models: Collection): string[];
|
38
|
+
declare function useKeys(models: Collection<any>): string[];
|
38
39
|
|
39
40
|
/**
|
40
41
|
* Get the min value of the specified filed.
|
package/dist/index.cjs
CHANGED
@@ -828,6 +828,8 @@ class Query {
|
|
828
828
|
this.getNewHydrated = true;
|
829
829
|
return this;
|
830
830
|
}
|
831
|
+
// where(field: T, value?: WhereSecondaryClosure<M[T]> | M[T]): this;
|
832
|
+
// where<T extends WherePrimaryClosure<M> | keyof M>(field: T, value?: WhereSecondaryClosure<M[T]> | M[T]): this;
|
831
833
|
/**
|
832
834
|
* Add a basic where clause to the query.
|
833
835
|
*/
|
@@ -842,8 +844,34 @@ class Query {
|
|
842
844
|
if (values instanceof Set) {
|
843
845
|
values = Array.from(values);
|
844
846
|
}
|
845
|
-
this.
|
846
|
-
|
847
|
+
return this.where(field, values);
|
848
|
+
}
|
849
|
+
/**
|
850
|
+
* Add a "where not in" clause to the query.
|
851
|
+
*/
|
852
|
+
whereNotIn(field, values) {
|
853
|
+
if (values instanceof Set) {
|
854
|
+
values = Array.from(values);
|
855
|
+
}
|
856
|
+
return this.where((query) => !values.includes(query[field]));
|
857
|
+
}
|
858
|
+
/**
|
859
|
+
* Add a "where not in" clause to the query.
|
860
|
+
*/
|
861
|
+
orWhereIn(field, values) {
|
862
|
+
if (values instanceof Set) {
|
863
|
+
values = Array.from(values);
|
864
|
+
}
|
865
|
+
return this.orWhere(field, values);
|
866
|
+
}
|
867
|
+
/**
|
868
|
+
* Add a "where not in" clause to the query.
|
869
|
+
*/
|
870
|
+
orWhereNotIn(field, values) {
|
871
|
+
if (values instanceof Set) {
|
872
|
+
values = Array.from(values);
|
873
|
+
}
|
874
|
+
return this.orWhere((query) => !values.includes(query[field]));
|
847
875
|
}
|
848
876
|
/**
|
849
877
|
* Add a where clause on the primary key to the query.
|
@@ -858,6 +886,18 @@ class Query {
|
|
858
886
|
this.wheres.push({ field, value, boolean: "or" });
|
859
887
|
return this;
|
860
888
|
}
|
889
|
+
/**
|
890
|
+
* Add a "whereNULL" clause to the query.
|
891
|
+
*/
|
892
|
+
whereNull(field) {
|
893
|
+
return this.where(field, null);
|
894
|
+
}
|
895
|
+
/**
|
896
|
+
* Add a "whereNotNULL" clause to the query.
|
897
|
+
*/
|
898
|
+
whereNotNull(field) {
|
899
|
+
return this.where((query) => query[field] != null);
|
900
|
+
}
|
861
901
|
/**
|
862
902
|
* Add a "where has" clause to the query.
|
863
903
|
*/
|
@@ -992,11 +1032,14 @@ class Query {
|
|
992
1032
|
*/
|
993
1033
|
getFieldWhereForRelations(relation, callback = () => {
|
994
1034
|
}, operator, count) {
|
995
|
-
const modelIdsByRelation = this.newQuery(this.model.$entity()).with(relation, callback).get(false).filter((model) =>
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1035
|
+
const modelIdsByRelation = this.newQuery(this.model.$entity()).with(relation, callback).get(false).filter((model) => {
|
1036
|
+
const modelRelation = model[relation];
|
1037
|
+
return Utils.compareWithOperator(
|
1038
|
+
Utils.isArray(modelRelation) ? modelRelation.length : modelRelation === null ? 0 : 1,
|
1039
|
+
typeof operator === "number" ? operator : count ?? 1,
|
1040
|
+
typeof operator === "number" || count === void 0 ? ">=" : operator
|
1041
|
+
);
|
1042
|
+
}).map((model) => model.$getIndexId());
|
1000
1043
|
return (model) => modelIdsByRelation.includes(model.$getIndexId());
|
1001
1044
|
}
|
1002
1045
|
/**
|
@@ -1052,13 +1095,13 @@ class Query {
|
|
1052
1095
|
this.where(this.model.$typeKey(), this.model.$fields()[this.model.$typeKey()].make());
|
1053
1096
|
}
|
1054
1097
|
let models = this.select();
|
1055
|
-
if (
|
1098
|
+
if (this.orders.length === 0) {
|
1056
1099
|
models = this.filterLimit(models);
|
1057
1100
|
}
|
1058
1101
|
if (!Utils.isEmpty(models)) {
|
1059
1102
|
this.eagerLoadRelations(models);
|
1060
1103
|
}
|
1061
|
-
if (this.orders) {
|
1104
|
+
if (this.orders.length > 0) {
|
1062
1105
|
models = this.filterOrder(models);
|
1063
1106
|
models = this.filterLimit(models);
|
1064
1107
|
}
|
@@ -1651,6 +1694,22 @@ class Repository {
|
|
1651
1694
|
this.database = database;
|
1652
1695
|
this.pinia = pinia;
|
1653
1696
|
this.hydratedDataCache = cache;
|
1697
|
+
return new Proxy(this, {
|
1698
|
+
get(repository, field) {
|
1699
|
+
if (typeof field === "symbol") {
|
1700
|
+
return;
|
1701
|
+
}
|
1702
|
+
if (field in repository) {
|
1703
|
+
return repository[field];
|
1704
|
+
}
|
1705
|
+
if (field === "use" || field === "model" || field === "queryCache") {
|
1706
|
+
return;
|
1707
|
+
}
|
1708
|
+
return function(...args) {
|
1709
|
+
return repository.query()[field](...args);
|
1710
|
+
};
|
1711
|
+
}
|
1712
|
+
});
|
1654
1713
|
}
|
1655
1714
|
/**
|
1656
1715
|
* Set the model
|
@@ -1858,9 +1917,6 @@ class Repository {
|
|
1858
1917
|
all() {
|
1859
1918
|
return this.query().get();
|
1860
1919
|
}
|
1861
|
-
find(ids) {
|
1862
|
-
return this.query().find(ids);
|
1863
|
-
}
|
1864
1920
|
revive(schema) {
|
1865
1921
|
return this.query().revive(schema);
|
1866
1922
|
}
|
@@ -2808,6 +2864,8 @@ class Model {
|
|
2808
2864
|
* Create a new model instance.
|
2809
2865
|
*/
|
2810
2866
|
constructor(attributes, options = { operation: "set" }) {
|
2867
|
+
// [s: keyof ModelFields]: any
|
2868
|
+
__publicField(this, "pivot");
|
2811
2869
|
this.$boot();
|
2812
2870
|
const fill = options.fill ?? true;
|
2813
2871
|
fill && this.$fill(attributes, options);
|
package/dist/index.d.cts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.
|
2
|
-
export { A as AfterHook,
|
1
|
+
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.b86abeaa.cjs';
|
2
|
+
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.b86abeaa.cjs';
|
3
3
|
import { Pinia } from 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/model/Model';
|
5
6
|
import '@/composables';
|
6
7
|
|
7
8
|
declare function useRepo<R extends Repository>(repository: R | Constructor<R>, pinia?: Pinia): R;
|
@@ -46,4 +47,4 @@ declare const config: FilledInstallOptions & {
|
|
46
47
|
[key: string]: any;
|
47
48
|
};
|
48
49
|
|
49
|
-
export { CONFIG_DEFAULTS, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
|
50
|
+
export { CONFIG_DEFAULTS, Constructor, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
|
package/dist/index.d.mts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.
|
2
|
-
export { A as AfterHook,
|
1
|
+
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.b86abeaa.mjs';
|
2
|
+
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.b86abeaa.mjs';
|
3
3
|
import { Pinia } from 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/model/Model';
|
5
6
|
import '@/composables';
|
6
7
|
|
7
8
|
declare function useRepo<R extends Repository>(repository: R | Constructor<R>, pinia?: Pinia): R;
|
@@ -46,4 +47,4 @@ declare const config: FilledInstallOptions & {
|
|
46
47
|
[key: string]: any;
|
47
48
|
};
|
48
49
|
|
49
|
-
export { CONFIG_DEFAULTS, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
|
50
|
+
export { CONFIG_DEFAULTS, Constructor, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.
|
2
|
-
export { A as AfterHook,
|
1
|
+
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.b86abeaa.js';
|
2
|
+
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.b86abeaa.js';
|
3
3
|
import { Pinia } from 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/model/Model';
|
5
6
|
import '@/composables';
|
6
7
|
|
7
8
|
declare function useRepo<R extends Repository>(repository: R | Constructor<R>, pinia?: Pinia): R;
|
@@ -46,4 +47,4 @@ declare const config: FilledInstallOptions & {
|
|
46
47
|
[key: string]: any;
|
47
48
|
};
|
48
49
|
|
49
|
-
export { CONFIG_DEFAULTS, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
|
50
|
+
export { CONFIG_DEFAULTS, Constructor, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
|
package/dist/index.mjs
CHANGED
@@ -826,6 +826,8 @@ class Query {
|
|
826
826
|
this.getNewHydrated = true;
|
827
827
|
return this;
|
828
828
|
}
|
829
|
+
// where(field: T, value?: WhereSecondaryClosure<M[T]> | M[T]): this;
|
830
|
+
// where<T extends WherePrimaryClosure<M> | keyof M>(field: T, value?: WhereSecondaryClosure<M[T]> | M[T]): this;
|
829
831
|
/**
|
830
832
|
* Add a basic where clause to the query.
|
831
833
|
*/
|
@@ -840,8 +842,34 @@ class Query {
|
|
840
842
|
if (values instanceof Set) {
|
841
843
|
values = Array.from(values);
|
842
844
|
}
|
843
|
-
this.
|
844
|
-
|
845
|
+
return this.where(field, values);
|
846
|
+
}
|
847
|
+
/**
|
848
|
+
* Add a "where not in" clause to the query.
|
849
|
+
*/
|
850
|
+
whereNotIn(field, values) {
|
851
|
+
if (values instanceof Set) {
|
852
|
+
values = Array.from(values);
|
853
|
+
}
|
854
|
+
return this.where((query) => !values.includes(query[field]));
|
855
|
+
}
|
856
|
+
/**
|
857
|
+
* Add a "where not in" clause to the query.
|
858
|
+
*/
|
859
|
+
orWhereIn(field, values) {
|
860
|
+
if (values instanceof Set) {
|
861
|
+
values = Array.from(values);
|
862
|
+
}
|
863
|
+
return this.orWhere(field, values);
|
864
|
+
}
|
865
|
+
/**
|
866
|
+
* Add a "where not in" clause to the query.
|
867
|
+
*/
|
868
|
+
orWhereNotIn(field, values) {
|
869
|
+
if (values instanceof Set) {
|
870
|
+
values = Array.from(values);
|
871
|
+
}
|
872
|
+
return this.orWhere((query) => !values.includes(query[field]));
|
845
873
|
}
|
846
874
|
/**
|
847
875
|
* Add a where clause on the primary key to the query.
|
@@ -856,6 +884,18 @@ class Query {
|
|
856
884
|
this.wheres.push({ field, value, boolean: "or" });
|
857
885
|
return this;
|
858
886
|
}
|
887
|
+
/**
|
888
|
+
* Add a "whereNULL" clause to the query.
|
889
|
+
*/
|
890
|
+
whereNull(field) {
|
891
|
+
return this.where(field, null);
|
892
|
+
}
|
893
|
+
/**
|
894
|
+
* Add a "whereNotNULL" clause to the query.
|
895
|
+
*/
|
896
|
+
whereNotNull(field) {
|
897
|
+
return this.where((query) => query[field] != null);
|
898
|
+
}
|
859
899
|
/**
|
860
900
|
* Add a "where has" clause to the query.
|
861
901
|
*/
|
@@ -990,11 +1030,14 @@ class Query {
|
|
990
1030
|
*/
|
991
1031
|
getFieldWhereForRelations(relation, callback = () => {
|
992
1032
|
}, operator, count) {
|
993
|
-
const modelIdsByRelation = this.newQuery(this.model.$entity()).with(relation, callback).get(false).filter((model) =>
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
1033
|
+
const modelIdsByRelation = this.newQuery(this.model.$entity()).with(relation, callback).get(false).filter((model) => {
|
1034
|
+
const modelRelation = model[relation];
|
1035
|
+
return compareWithOperator(
|
1036
|
+
isArray(modelRelation) ? modelRelation.length : modelRelation === null ? 0 : 1,
|
1037
|
+
typeof operator === "number" ? operator : count ?? 1,
|
1038
|
+
typeof operator === "number" || count === void 0 ? ">=" : operator
|
1039
|
+
);
|
1040
|
+
}).map((model) => model.$getIndexId());
|
998
1041
|
return (model) => modelIdsByRelation.includes(model.$getIndexId());
|
999
1042
|
}
|
1000
1043
|
/**
|
@@ -1050,13 +1093,13 @@ class Query {
|
|
1050
1093
|
this.where(this.model.$typeKey(), this.model.$fields()[this.model.$typeKey()].make());
|
1051
1094
|
}
|
1052
1095
|
let models = this.select();
|
1053
|
-
if (
|
1096
|
+
if (this.orders.length === 0) {
|
1054
1097
|
models = this.filterLimit(models);
|
1055
1098
|
}
|
1056
1099
|
if (!isEmpty(models)) {
|
1057
1100
|
this.eagerLoadRelations(models);
|
1058
1101
|
}
|
1059
|
-
if (this.orders) {
|
1102
|
+
if (this.orders.length > 0) {
|
1060
1103
|
models = this.filterOrder(models);
|
1061
1104
|
models = this.filterLimit(models);
|
1062
1105
|
}
|
@@ -1649,6 +1692,22 @@ class Repository {
|
|
1649
1692
|
this.database = database;
|
1650
1693
|
this.pinia = pinia;
|
1651
1694
|
this.hydratedDataCache = cache;
|
1695
|
+
return new Proxy(this, {
|
1696
|
+
get(repository, field) {
|
1697
|
+
if (typeof field === "symbol") {
|
1698
|
+
return;
|
1699
|
+
}
|
1700
|
+
if (field in repository) {
|
1701
|
+
return repository[field];
|
1702
|
+
}
|
1703
|
+
if (field === "use" || field === "model" || field === "queryCache") {
|
1704
|
+
return;
|
1705
|
+
}
|
1706
|
+
return function(...args) {
|
1707
|
+
return repository.query()[field](...args);
|
1708
|
+
};
|
1709
|
+
}
|
1710
|
+
});
|
1652
1711
|
}
|
1653
1712
|
/**
|
1654
1713
|
* Set the model
|
@@ -1856,9 +1915,6 @@ class Repository {
|
|
1856
1915
|
all() {
|
1857
1916
|
return this.query().get();
|
1858
1917
|
}
|
1859
|
-
find(ids) {
|
1860
|
-
return this.query().find(ids);
|
1861
|
-
}
|
1862
1918
|
revive(schema) {
|
1863
1919
|
return this.query().revive(schema);
|
1864
1920
|
}
|
@@ -2806,6 +2862,8 @@ class Model {
|
|
2806
2862
|
* Create a new model instance.
|
2807
2863
|
*/
|
2808
2864
|
constructor(attributes, options = { operation: "set" }) {
|
2865
|
+
// [s: keyof ModelFields]: any
|
2866
|
+
__publicField(this, "pivot");
|
2809
2867
|
this.$boot();
|
2810
2868
|
const fill = options.fill ?? true;
|
2811
2869
|
fill && this.$fill(attributes, options);
|
package/dist/nanoid/async.d.cts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
/**
|
package/dist/nanoid/async.d.mts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
/**
|
package/dist/nanoid/async.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
/**
|
package/dist/nanoid/index.d.cts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
package/dist/nanoid/index.d.mts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
package/dist/nanoid/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
+
import '@/model/Model';
|
4
5
|
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|