fib-orm 1.4.2 → 2.1.0
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/License +1 -1
- package/README.md +53 -0
- package/lib/cli/commands/ddlFrom.d.ts +2 -0
- package/lib/cli/commands/ddlFrom.js +75 -0
- package/lib/cli/commands/dumpModel.d.ts +2 -0
- package/lib/cli/commands/dumpModel.js +107 -0
- package/lib/cli/commands/escape.d.ts +2 -0
- package/lib/cli/commands/escape.js +69 -0
- package/lib/cli/commands/spinner.d.ts +2 -0
- package/lib/cli/commands/spinner.js +37 -0
- package/lib/cli/commands/upgrade.d.ts +2 -0
- package/lib/cli/commands/upgrade.js +66 -0
- package/lib/cli/helpers/ddl.d.ts +17 -0
- package/lib/cli/helpers/ddl.js +55 -0
- package/lib/cli/helpers/package.d.ts +25 -0
- package/lib/cli/helpers/package.js +56 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +19 -0
- package/lib/codepoints-map.json +762 -0
- package/lib/db-driver/Typo.d.ts +111 -0
- package/lib/db-driver/Typo.js +2 -0
- package/lib/db-driver/built-ins/base.class.d.ts +91 -0
- package/lib/db-driver/built-ins/base.class.js +187 -0
- package/lib/db-driver/built-ins/driver-dm.d.ts +17 -0
- package/lib/db-driver/built-ins/driver-dm.js +54 -0
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +23 -0
- package/lib/db-driver/built-ins/driver-mongodb.js +47 -0
- package/lib/db-driver/built-ins/driver-mysql.d.ts +17 -0
- package/lib/db-driver/built-ins/driver-mysql.js +38 -0
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +21 -0
- package/lib/db-driver/built-ins/driver-postgresql.js +77 -0
- package/lib/db-driver/built-ins/driver-redis.d.ts +11 -0
- package/lib/db-driver/built-ins/driver-redis.js +36 -0
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +16 -0
- package/lib/db-driver/built-ins/driver-sqlite.js +35 -0
- package/lib/db-driver/index.d.ts +3 -0
- package/lib/db-driver/index.js +5 -0
- package/lib/db-driver/utils.d.ts +14 -0
- package/lib/db-driver/utils.js +187 -0
- package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +12 -0
- package/lib/knex/deps/tarn/dist/PendingOperation.js +48 -0
- package/lib/knex/deps/tarn/dist/Pool.d.ts +97 -0
- package/lib/knex/deps/tarn/dist/Pool.js +516 -0
- package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +16 -0
- package/lib/knex/deps/tarn/dist/PromiseInspection.js +21 -0
- package/lib/knex/deps/tarn/dist/Resource.d.ts +9 -0
- package/lib/knex/deps/tarn/dist/Resource.js +19 -0
- package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +2 -0
- package/lib/knex/deps/tarn/dist/TimeoutError.js +5 -0
- package/lib/knex/deps/tarn/dist/tarn.d.ts +3 -0
- package/lib/knex/deps/tarn/dist/tarn.js +10 -0
- package/lib/knex/deps/tarn/dist/utils.d.ts +14 -0
- package/lib/knex/deps/tarn/dist/utils.js +60 -0
- package/lib/knex/knex.d.ts +2 -0
- package/lib/knex/knex.js +4 -0
- package/lib/knex/sandbox.d.ts +4 -0
- package/lib/knex/sandbox.js +23 -0
- package/lib/orm/Adapters.d.ts +3 -0
- package/lib/orm/Adapters.js +44 -0
- package/lib/orm/AggregateFunctions.d.ts +3 -0
- package/lib/orm/AggregateFunctions.js +177 -0
- package/lib/orm/Associations/Extend.d.ts +22 -0
- package/lib/orm/Associations/Extend.js +274 -0
- package/lib/orm/Associations/Many.d.ts +16 -0
- package/lib/orm/Associations/Many.js +569 -0
- package/lib/orm/Associations/One.d.ts +16 -0
- package/lib/orm/Associations/One.js +310 -0
- package/lib/orm/Associations/_utils.d.ts +14 -0
- package/lib/orm/Associations/_utils.js +53 -0
- package/lib/orm/ChainFind.d.ts +3 -0
- package/lib/orm/ChainFind.js +328 -0
- package/lib/orm/ChainInstance.d.ts +6 -0
- package/lib/orm/ChainInstance.js +74 -0
- package/lib/orm/Debug.d.ts +2 -0
- package/lib/orm/Debug.js +17 -0
- package/lib/orm/Drivers/DB/base.d.ts +2 -0
- package/lib/orm/Drivers/DB/base.js +4 -0
- package/lib/orm/Drivers/DB/dm.d.ts +9 -0
- package/lib/orm/Drivers/DB/dm.js +24 -0
- package/lib/orm/Drivers/DB/mysql.d.ts +9 -0
- package/lib/orm/Drivers/DB/mysql.js +24 -0
- package/lib/orm/Drivers/DB/postgres.d.ts +9 -0
- package/lib/orm/Drivers/DB/postgres.js +23 -0
- package/lib/orm/Drivers/DB/sqlite3.d.ts +14 -0
- package/lib/orm/Drivers/DB/sqlite3.js +40 -0
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +3 -0
- package/lib/orm/Drivers/DML/_ddl-sql.js +52 -0
- package/lib/orm/Drivers/DML/_dml-helpers.d.ts +19 -0
- package/lib/orm/Drivers/DML/_dml-helpers.js +51 -0
- package/lib/orm/Drivers/DML/_shared.d.ts +9 -0
- package/lib/orm/Drivers/DML/_shared.js +39 -0
- package/lib/orm/Drivers/DML/_utils.d.ts +8 -0
- package/lib/orm/Drivers/DML/_utils.js +67 -0
- package/lib/orm/Drivers/DML/constants.d.ts +3 -0
- package/lib/orm/Drivers/DML/constants.js +3 -0
- package/lib/orm/Drivers/DML/dm.d.ts +2 -0
- package/lib/orm/Drivers/DML/dm.js +294 -0
- package/lib/orm/Drivers/DML/index.d.ts +4 -0
- package/lib/orm/Drivers/DML/index.js +7 -0
- package/lib/orm/Drivers/DML/mysql.d.ts +2 -0
- package/lib/orm/Drivers/DML/mysql.js +252 -0
- package/lib/orm/Drivers/DML/postgres.d.ts +2 -0
- package/lib/orm/Drivers/DML/postgres.js +277 -0
- package/lib/orm/Drivers/DML/sqlite.d.ts +2 -0
- package/lib/orm/Drivers/DML/sqlite.js +267 -0
- package/lib/orm/Error.d.ts +11 -0
- package/lib/orm/Error.js +41 -0
- package/lib/orm/Helpers.d.ts +35 -0
- package/lib/orm/Helpers.js +234 -0
- package/lib/orm/Hook.d.ts +13 -0
- package/lib/orm/Hook.js +100 -0
- package/lib/orm/Instance.d.ts +2 -0
- package/lib/orm/Instance.js +698 -0
- package/lib/orm/LazyLoad.d.ts +4 -0
- package/lib/orm/LazyLoad.js +76 -0
- package/lib/orm/Model.d.ts +6 -0
- package/lib/orm/Model.js +974 -0
- package/lib/orm/ORM.d.ts +37 -0
- package/lib/orm/ORM.js +242 -0
- package/lib/orm/Patch/fib-cache.d.ts +39 -0
- package/lib/orm/Patch/fib-cache.js +2 -0
- package/lib/orm/Patch/plugin.d.ts +4 -0
- package/lib/orm/Patch/plugin.js +14 -0
- package/lib/orm/Property.d.ts +9 -0
- package/lib/orm/Property.js +71 -0
- package/lib/orm/Settings.d.ts +42 -0
- package/lib/orm/Settings.js +120 -0
- package/lib/orm/Singleton.d.ts +5 -0
- package/lib/orm/Singleton.js +73 -0
- package/lib/orm/Typo/Adapter.d.ts +5 -0
- package/lib/orm/Typo/Adapter.js +2 -0
- package/lib/orm/Typo/DMLDriver.d.ts +209 -0
- package/lib/orm/Typo/DMLDriver.js +2 -0
- package/lib/orm/Typo/Db.d.ts +35 -0
- package/lib/orm/Typo/Db.js +2 -0
- package/lib/orm/Typo/Error.d.ts +29 -0
- package/lib/orm/Typo/Error.js +2 -0
- package/lib/orm/Typo/ORM.d.ts +231 -0
- package/lib/orm/Typo/ORM.js +4 -0
- package/lib/orm/Typo/Validators.d.ts +31 -0
- package/lib/orm/Typo/Validators.js +3 -0
- package/lib/orm/Typo/_common.d.ts +37 -0
- package/lib/orm/Typo/_common.js +2 -0
- package/lib/orm/Typo/assoc.d.ts +221 -0
- package/lib/orm/Typo/assoc.js +2 -0
- package/lib/orm/Typo/hook.d.ts +42 -0
- package/lib/orm/Typo/hook.js +2 -0
- package/lib/orm/Typo/instance.d.ts +156 -0
- package/lib/orm/Typo/instance.js +2 -0
- package/lib/orm/Typo/model.d.ts +311 -0
- package/lib/orm/Typo/model.js +7 -0
- package/lib/orm/Typo/patch.d.ts +31 -0
- package/lib/orm/Typo/patch.js +2 -0
- package/lib/orm/Typo/property.d.ts +57 -0
- package/lib/orm/Typo/property.js +2 -0
- package/lib/orm/Typo/query.d.ts +216 -0
- package/lib/orm/Typo/query.js +2 -0
- package/lib/orm/Typo/settings.d.ts +35 -0
- package/lib/orm/Typo/settings.js +6 -0
- package/lib/orm/Typo/synchronous.d.ts +47 -0
- package/lib/orm/Typo/synchronous.js +2 -0
- package/lib/orm/Utilities.d.ts +178 -0
- package/lib/orm/Utilities.js +975 -0
- package/lib/orm/Validators.d.ts +33 -0
- package/lib/orm/Validators.js +101 -0
- package/lib/orm/Where/common.d.ts +1 -0
- package/lib/orm/Where/common.js +7 -0
- package/lib/orm/Where/filterDate.d.ts +11 -0
- package/lib/orm/Where/filterDate.js +58 -0
- package/lib/orm/index.d.ts +67 -0
- package/lib/orm/index.js +158 -0
- package/lib/orm-core/callback.d.ts +12 -0
- package/lib/orm-core/callback.js +2 -0
- package/lib/orm-core/dialect.d.ts +80 -0
- package/lib/orm-core/dialect.js +2 -0
- package/lib/orm-core/error.d.ts +16 -0
- package/lib/orm-core/error.js +29 -0
- package/lib/orm-core/index.d.ts +6 -0
- package/lib/orm-core/index.js +7 -0
- package/lib/orm-core/sync.d.ts +12 -0
- package/lib/orm-core/sync.js +2 -0
- package/lib/orm-core/utils.d.ts +1 -0
- package/lib/orm-core/utils.js +6 -0
- package/lib/orm-property/Property.d.ts +78 -0
- package/lib/orm-property/Property.js +2 -0
- package/lib/orm-property/Utils.d.ts +9 -0
- package/lib/orm-property/Utils.js +13 -0
- package/lib/orm-property/customTypes.d.ts +2 -0
- package/lib/orm-property/customTypes.js +13 -0
- package/lib/orm-property/index.d.ts +10 -0
- package/lib/orm-property/index.js +23 -0
- package/lib/orm-property/transformer.d.ts +5 -0
- package/lib/orm-property/transformer.js +10 -0
- package/lib/orm-property/transformers/dm.d.ts +29 -0
- package/lib/orm-property/transformers/dm.js +238 -0
- package/lib/orm-property/transformers/index.d.ts +4 -0
- package/lib/orm-property/transformers/index.js +6 -0
- package/lib/orm-property/transformers/mysql.d.ts +101 -0
- package/lib/orm-property/transformers/mysql.js +262 -0
- package/lib/orm-property/transformers/postgresql.d.ts +54 -0
- package/lib/orm-property/transformers/postgresql.js +190 -0
- package/lib/orm-property/transformers/sqlite.d.ts +19 -0
- package/lib/orm-property/transformers/sqlite.js +172 -0
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +39 -0
- package/lib/sql-ddl-sync/Dialects/dm.js +297 -0
- package/lib/sql-ddl-sync/Dialects/index.d.ts +6 -0
- package/lib/sql-ddl-sync/Dialects/index.js +8 -0
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +38 -0
- package/lib/sql-ddl-sync/Dialects/mysql.js +241 -0
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +39 -0
- package/lib/sql-ddl-sync/Dialects/postgresql.js +287 -0
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +43 -0
- package/lib/sql-ddl-sync/Dialects/sqlite.js +257 -0
- package/lib/sql-ddl-sync/SQL.d.ts +12 -0
- package/lib/sql-ddl-sync/SQL.js +108 -0
- package/lib/sql-ddl-sync/Typo/Collection.d.ts +13 -0
- package/lib/sql-ddl-sync/Typo/Collection.js +2 -0
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +13 -0
- package/lib/sql-ddl-sync/Typo/DbIndex.js +2 -0
- package/lib/sql-ddl-sync/Typo/Dialect.d.ts +81 -0
- package/lib/sql-ddl-sync/Typo/Dialect.js +2 -0
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +53 -0
- package/lib/sql-ddl-sync/Typo/Driver.js +2 -0
- package/lib/sql-ddl-sync/Typo/Query.d.ts +7 -0
- package/lib/sql-ddl-sync/Typo/Query.js +2 -0
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +31 -0
- package/lib/sql-ddl-sync/Typo/SQL.js +2 -0
- package/lib/sql-ddl-sync/Typo/_common.d.ts +29 -0
- package/lib/sql-ddl-sync/Typo/_common.js +2 -0
- package/lib/sql-ddl-sync/Utils.d.ts +39 -0
- package/lib/sql-ddl-sync/Utils.js +217 -0
- package/lib/sql-ddl-sync/index.d.ts +87 -0
- package/lib/sql-ddl-sync/index.js +372 -0
- package/lib/sql-query/Comparators.d.ts +3 -0
- package/lib/sql-query/Comparators.js +95 -0
- package/lib/sql-query/Create.d.ts +35 -0
- package/lib/sql-query/Create.js +78 -0
- package/lib/sql-query/Dialects/dm.d.ts +3 -0
- package/lib/sql-query/Dialects/dm.js +75 -0
- package/lib/sql-query/Dialects/index.d.ts +10 -0
- package/lib/sql-query/Dialects/index.js +13 -0
- package/lib/sql-query/Dialects/mssql.d.ts +3 -0
- package/lib/sql-query/Dialects/mssql.js +74 -0
- package/lib/sql-query/Dialects/mysql.d.ts +3 -0
- package/lib/sql-query/Dialects/mysql.js +101 -0
- package/lib/sql-query/Dialects/postgresql.d.ts +3 -0
- package/lib/sql-query/Dialects/postgresql.js +77 -0
- package/lib/sql-query/Dialects/sqlite.d.ts +3 -0
- package/lib/sql-query/Dialects/sqlite.js +62 -0
- package/lib/sql-query/Helpers.d.ts +37 -0
- package/lib/sql-query/Helpers.js +260 -0
- package/lib/sql-query/Insert.d.ts +12 -0
- package/lib/sql-query/Insert.js +34 -0
- package/lib/sql-query/Query.d.ts +28 -0
- package/lib/sql-query/Query.js +120 -0
- package/lib/sql-query/Remove.d.ts +16 -0
- package/lib/sql-query/Remove.js +94 -0
- package/lib/sql-query/Select.d.ts +62 -0
- package/lib/sql-query/Select.js +534 -0
- package/lib/sql-query/Set.d.ts +4 -0
- package/lib/sql-query/Set.js +16 -0
- package/lib/sql-query/Typo/Aggregation.d.ts +32 -0
- package/lib/sql-query/Typo/Aggregation.js +2 -0
- package/lib/sql-query/Typo/Comparators.d.ts +140 -0
- package/lib/sql-query/Typo/Comparators.js +2 -0
- package/lib/sql-query/Typo/Dialect.d.ts +39 -0
- package/lib/sql-query/Typo/Dialect.js +2 -0
- package/lib/sql-query/Typo/Field.d.ts +8 -0
- package/lib/sql-query/Typo/Field.js +2 -0
- package/lib/sql-query/Typo/Helper.d.ts +4 -0
- package/lib/sql-query/Typo/Helper.js +2 -0
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +80 -0
- package/lib/sql-query/Typo/Query-ChainBuilder.js +2 -0
- package/lib/sql-query/Typo/Query.d.ts +34 -0
- package/lib/sql-query/Typo/Query.js +17 -0
- package/lib/sql-query/Typo/Sql.d.ts +143 -0
- package/lib/sql-query/Typo/Sql.js +2 -0
- package/lib/sql-query/Typo/SubQuery.d.ts +39 -0
- package/lib/sql-query/Typo/SubQuery.js +2 -0
- package/lib/sql-query/Typo/index.d.ts +9 -0
- package/lib/sql-query/Typo/index.js +2 -0
- package/lib/sql-query/Update.d.ts +15 -0
- package/lib/sql-query/Update.js +39 -0
- package/lib/sql-query/Where.d.ts +4 -0
- package/lib/sql-query/Where.js +280 -0
- package/package.json +71 -36
- package/.travis.yml +0 -14
- package/@types/index.d.ts +0 -254
- package/@types/orm_mirror/orm.d.ts +0 -275
- package/@types/orm_mirror/sql-query.d.ts +0 -79
- package/Readme.md +0 -843
- package/lib/index.js +0 -13
- package/lib/modules/mysql.js +0 -35
- package/lib/modules/sqlite3.js +0 -27
- package/lib/patch.js +0 -271
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import type { FxOrmSqlDDLSync } from "../../sql-ddl-sync/index";
|
|
2
|
+
import { FxOrmAssociation } from "./assoc";
|
|
3
|
+
import { FxOrmInstance } from "./instance";
|
|
4
|
+
import { FxOrmProperty } from "./property";
|
|
5
|
+
import { FxOrmSettings } from "./settings";
|
|
6
|
+
import { FxOrmCommon } from "./_common";
|
|
7
|
+
import { FxOrmSynchronous } from "./synchronous";
|
|
8
|
+
import { FxOrmQuery } from "./query";
|
|
9
|
+
import { FxOrmValidators } from "./Validators";
|
|
10
|
+
import { FxOrmHook } from "./hook";
|
|
11
|
+
import { FxOrmNS } from "./ORM";
|
|
12
|
+
import type { FxSqlQuerySubQuery, FxSqlQuerySql, FxSqlQueryChainBuilder } from '../../sql-query/Query';
|
|
13
|
+
import { FxOrmError } from "./Error";
|
|
14
|
+
export declare namespace FxOrmModel {
|
|
15
|
+
export type ModelInstanceConstructorOptions = (string | number | FxOrmInstance.InstanceDataPayload)[];
|
|
16
|
+
export type OrderListOrLimitOffer = number | string | string[];
|
|
17
|
+
export interface Model<PropertyTypes extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>, Methods extends Record<string, (...args: any) => any> = Record<string, (...args: any) => any>> extends ModelHooksModifier, FxOrmSynchronous.SynchronizedModel<PropertyTypes, Methods> {
|
|
18
|
+
(): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
19
|
+
new (): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
20
|
+
(...data: ModelInstanceConstructorOptions): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
21
|
+
new (...data: ModelInstanceConstructorOptions): FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
22
|
+
name: string;
|
|
23
|
+
properties: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
24
|
+
settings: FxOrmSettings.SettingInstance;
|
|
25
|
+
table: string;
|
|
26
|
+
id: string[];
|
|
27
|
+
uid: string;
|
|
28
|
+
caches: import('fib-cache').LRU;
|
|
29
|
+
keys: string[];
|
|
30
|
+
allProperties: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
31
|
+
virtualProperties: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
32
|
+
addProperty(propIn: FxOrmProperty.NormalizedProperty, options?: {
|
|
33
|
+
name?: string;
|
|
34
|
+
klass?: FxOrmProperty.KlassType;
|
|
35
|
+
} | false): FxOrmProperty.NormalizedProperty;
|
|
36
|
+
/** @internal */
|
|
37
|
+
readonly __propertiesByName: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
38
|
+
sync(callback?: FxOrmCommon.GenericCallback<FxOrmSqlDDLSync.SyncResult>): Model;
|
|
39
|
+
drop(callback?: FxOrmCommon.VoidCallback): Model;
|
|
40
|
+
/**
|
|
41
|
+
* methods used to add associations
|
|
42
|
+
*/
|
|
43
|
+
hasOne: {
|
|
44
|
+
(assoc_name: string, ext_model?: Model, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasOne): FxOrmModel.Model;
|
|
45
|
+
};
|
|
46
|
+
hasMany: {
|
|
47
|
+
(assoc_name: string, ext_model: Model, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany): FxOrmModel.Model;
|
|
48
|
+
(assoc_name: string, ext_model: Model, assoc_props: Record<string, ModelPropertyDefinition>, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_HasMany): FxOrmModel.Model;
|
|
49
|
+
};
|
|
50
|
+
extendsTo: {
|
|
51
|
+
(name: string, properties: Record<string, ModelPropertyDefinition>, assoc_options?: FxOrmAssociation.AssociationDefinitionOptions_ExtendsTo): Model;
|
|
52
|
+
};
|
|
53
|
+
associations: {
|
|
54
|
+
[k: string]: {
|
|
55
|
+
type: 'hasOne';
|
|
56
|
+
association: FxOrmAssociation.InstanceAssociationItem_HasOne;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'hasMany';
|
|
59
|
+
association: FxOrmAssociation.InstanceAssociationItem_HasMany;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'extendsTo';
|
|
62
|
+
association: FxOrmAssociation.InstanceAssociationItem_ExtendTos;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
findBy: {
|
|
66
|
+
<T = any>(association_name: ModelFindByDescriptorItem['association_name'], conditions?: ModelFindByDescriptorItem['conditions'], options?: ModelFindByDescriptorItem['options'], cb?: FxOrmCommon.ExecutionCallback<T>): FxOrmQuery.IChainFind;
|
|
67
|
+
<T = any>(list: ModelFindByDescriptorItem[], self_conditions: FxOrmQuery.QueryConditions__Find, options?: ModelFindByDescriptorItem['options'], cb?: FxOrmCommon.ExecutionCallback<T>): FxOrmQuery.IChainFind;
|
|
68
|
+
};
|
|
69
|
+
create: {
|
|
70
|
+
(data: FxOrmInstance.InstanceDataPayload, callback?: ModelMethodCallback__CreateItem): typeof data extends any[] ? FxOrmInstance.Instance<PropertyTypes, Methods>[] : FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
71
|
+
(data: FxOrmInstance.InstanceDataPayload, options?: ModelOptions__Create, callback?: ModelMethodCallback__CreateItem): typeof data extends any[] ? FxOrmInstance.Instance<PropertyTypes, Methods>[] : FxOrmInstance.Instance<PropertyTypes, Methods>;
|
|
72
|
+
};
|
|
73
|
+
clear(...args: any[]): this;
|
|
74
|
+
get(...ids: any[]): this;
|
|
75
|
+
chain: {
|
|
76
|
+
(conditions?: FxOrmQuery.QueryConditions__Find, ...args: (FxOrmModel.ModelOptions__Find | OrderListOrLimitOffer)[]): FxOrmQuery.IChainFind;
|
|
77
|
+
};
|
|
78
|
+
find(conditions?: FxOrmQuery.QueryConditions__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
79
|
+
find(callback: ModelMethodCallback__Find): this;
|
|
80
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Find): this;
|
|
81
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
82
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find, callback: ModelMethodCallback__Find): this;
|
|
83
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order?: OrderListOrLimitOffer, limit_order2?: OrderListOrLimitOffer): FxOrmQuery.IChainFind<PropertyTypes, Methods>;
|
|
84
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order: OrderListOrLimitOffer, callback: ModelMethodCallback__Find): this;
|
|
85
|
+
find(conditions: FxOrmQuery.QueryConditions__Find, limit_order: OrderListOrLimitOffer, limit_order2: OrderListOrLimitOffer, callback: ModelMethodCallback__Find): this;
|
|
86
|
+
all: this['find'];
|
|
87
|
+
where: this['find'];
|
|
88
|
+
/**
|
|
89
|
+
* not like other methods, you must provide callback to those methods
|
|
90
|
+
* - `one`
|
|
91
|
+
* - `count`
|
|
92
|
+
* - `exists`
|
|
93
|
+
*
|
|
94
|
+
* that's maybe due to their purpose: always return Model rather than IChainFind
|
|
95
|
+
*/
|
|
96
|
+
one: {
|
|
97
|
+
(callback: ModelMethodCallback__Get): Model;
|
|
98
|
+
(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Get): Model;
|
|
99
|
+
(conditions: FxOrmQuery.QueryConditions__Find, options: ModelOptions__Find, callback: ModelMethodCallback__Get): Model;
|
|
100
|
+
(conditions: FxOrmQuery.QueryConditions__Find, order: string[], callback: ModelMethodCallback__Get): Model;
|
|
101
|
+
(conditions: FxOrmQuery.QueryConditions__Find, limit: number, callback: ModelMethodCallback__Get): Model;
|
|
102
|
+
};
|
|
103
|
+
count: {
|
|
104
|
+
(callback: ModelMethodCallback__Count): Model;
|
|
105
|
+
(conditions: FxOrmQuery.QueryConditions__Find, callback: ModelMethodCallback__Count): Model;
|
|
106
|
+
};
|
|
107
|
+
exists: {
|
|
108
|
+
(...conditions: (FxOrmCommon.IdType | FxSqlQuerySubQuery.SubQueryConditions | FxOrmCommon.ExecutionCallback<boolean>)[]): FxOrmQuery.IChainFind;
|
|
109
|
+
};
|
|
110
|
+
aggregate: {
|
|
111
|
+
(conditions: FxOrmQuery.QueryConditions__Find): FxOrmQuery.IAggregated;
|
|
112
|
+
(properties: string[]): FxOrmQuery.IAggregated;
|
|
113
|
+
(conditions: FxOrmQuery.QueryConditions__Find, properties: string[]): FxOrmQuery.IAggregated;
|
|
114
|
+
};
|
|
115
|
+
prependValidation: {
|
|
116
|
+
(key: string, validation: FibjsEnforce.IValidator): void;
|
|
117
|
+
};
|
|
118
|
+
[property: string]: any;
|
|
119
|
+
}
|
|
120
|
+
export type GetInstanceTypeFrom<T> = T extends Model<infer U, infer S> ? FxOrmInstance.Instance<U, S> : never;
|
|
121
|
+
export type FindByListStyleFunctionArgs<T = any> = [
|
|
122
|
+
FxOrmModel.ModelFindByDescriptorItem[],
|
|
123
|
+
FxOrmQuery.QueryConditions__Find,
|
|
124
|
+
FxOrmModel.ModelOptions__Find,
|
|
125
|
+
FxOrmCommon.ExecutionCallback<T>
|
|
126
|
+
];
|
|
127
|
+
export type FindByItemStyleFunctionArgs<T = any> = [
|
|
128
|
+
FxOrmModel.ModelFindByDescriptorItem['association_name'],
|
|
129
|
+
FxOrmModel.ModelFindByDescriptorItem['conditions'],
|
|
130
|
+
FxOrmModel.ModelFindByDescriptorItem['options'],
|
|
131
|
+
FxOrmCommon.ExecutionCallback<T>
|
|
132
|
+
];
|
|
133
|
+
export interface ModelFindByDescriptorItem {
|
|
134
|
+
association_name: string;
|
|
135
|
+
conditions?: FxOrmQuery.QueryConditions__Find;
|
|
136
|
+
options?: FxOrmAssociation.ModelAssociationMethod__FindByOptions;
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated extra where conditions fields for hasmany-assoc
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
join_where?: FxOrmAssociation.ModelAssociationMethod__FindOptions['join_where'];
|
|
142
|
+
extra_select?: string[];
|
|
143
|
+
}
|
|
144
|
+
export interface ModelConstructorOptions<TProperties extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>> {
|
|
145
|
+
name: string;
|
|
146
|
+
db: FxOrmNS.ORM;
|
|
147
|
+
settings: FxOrmSettings.SettingInstance;
|
|
148
|
+
driver_name: string;
|
|
149
|
+
driver: FxOrmQuery.ChainFindOptions['driver'];
|
|
150
|
+
table: FxOrmQuery.ChainFindOptions['table'];
|
|
151
|
+
tableComment: string;
|
|
152
|
+
generateSqlSelect?: FxOrmQuery.ChainFindOptions['generateSqlSelect'];
|
|
153
|
+
properties: Record<keyof TProperties, FxOrmProperty.NormalizedProperty>;
|
|
154
|
+
/** @internal */
|
|
155
|
+
__for_extension: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* @description if enabled, this model will be a virtual model,
|
|
158
|
+
* all Properties will be coerced to virtual property
|
|
159
|
+
*/
|
|
160
|
+
virtualView: {
|
|
161
|
+
disabled?: boolean;
|
|
162
|
+
subQuery: `(${string})`;
|
|
163
|
+
};
|
|
164
|
+
indexes: string[];
|
|
165
|
+
identityCache: boolean;
|
|
166
|
+
instanceCacheSize: number;
|
|
167
|
+
keys: FxOrmQuery.ChainFindOptions['keys'];
|
|
168
|
+
autoSave: boolean;
|
|
169
|
+
autoFetch: boolean;
|
|
170
|
+
autoFetchLimit: number;
|
|
171
|
+
cascadeRemove: boolean;
|
|
172
|
+
hooks: Hooks<FxOrmInstance.Instance<TProperties>>;
|
|
173
|
+
methods: Record<string, (this: FxOrmInstance.Instance<TProperties>, ...args: any) => any>;
|
|
174
|
+
validations: FxOrmValidators.IValidatorHash;
|
|
175
|
+
ievents: FxOrmInstance.InstanceConstructorOptions['events'];
|
|
176
|
+
}
|
|
177
|
+
type __ItOrItsArray<T> = T | T[];
|
|
178
|
+
export interface ModelDefineOptions<TProperties extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>> {
|
|
179
|
+
/**
|
|
180
|
+
* pririoty: table > collection
|
|
181
|
+
*/
|
|
182
|
+
table?: ModelConstructorOptions<TProperties>['table'];
|
|
183
|
+
/**
|
|
184
|
+
* @advanced
|
|
185
|
+
* @description use to specify the query source on DMLDriver's `find` excution,
|
|
186
|
+
*
|
|
187
|
+
* if enable this, then:
|
|
188
|
+
* - `table` will be ignored on generate SQL select
|
|
189
|
+
* - all put-like operations will be disabled for this model
|
|
190
|
+
* - `generateSqlSelect` would be ignored
|
|
191
|
+
*
|
|
192
|
+
* @warning if use this option, you must ensure the `selectTableSource` is a valid
|
|
193
|
+
*/
|
|
194
|
+
customSelect?: __ItOrItsArray<{
|
|
195
|
+
from: __ItOrItsArray<FxSqlQuerySql.SqlTableInputType>;
|
|
196
|
+
select?: FxSqlQuerySql.SqlSelectFieldsType[];
|
|
197
|
+
wheres?: string | Parameters<FxSqlQueryChainBuilder.ChainBuilder__Select['where']>[0] & object;
|
|
198
|
+
}>;
|
|
199
|
+
generateSqlSelect?: ModelConstructorOptions<TProperties>['generateSqlSelect'];
|
|
200
|
+
virtualView?: false | string | FxSqlQuerySql.SqlFromTableInput | ModelConstructorOptions<TProperties>['virtualView'];
|
|
201
|
+
collection?: ModelConstructorOptions<TProperties>['table'];
|
|
202
|
+
tableComment?: ModelConstructorOptions<TProperties>['tableComment'];
|
|
203
|
+
/**
|
|
204
|
+
* @dirty would be deprecated
|
|
205
|
+
*/
|
|
206
|
+
__for_extension?: ModelConstructorOptions<TProperties>['__for_extension'];
|
|
207
|
+
indexes?: ModelConstructorOptions<TProperties>['indexes'];
|
|
208
|
+
id?: ModelConstructorOptions<TProperties>['keys'];
|
|
209
|
+
autoSave?: ModelConstructorOptions<TProperties>['autoSave'];
|
|
210
|
+
autoFetch?: ModelConstructorOptions<TProperties>['autoFetch'];
|
|
211
|
+
autoFetchLimit?: ModelConstructorOptions<TProperties>['autoFetchLimit'];
|
|
212
|
+
hooks?: ModelConstructorOptions<TProperties>['hooks'];
|
|
213
|
+
validations?: ModelConstructorOptions<TProperties>['validations'];
|
|
214
|
+
methods?: Record<string, (this: FxOrmInstance.Instance<TProperties>, ...args: any) => any>;
|
|
215
|
+
identityCache?: ModelConstructorOptions<TProperties>['identityCache'];
|
|
216
|
+
cascadeRemove?: ModelConstructorOptions<TProperties>['cascadeRemove'];
|
|
217
|
+
ievents?: ModelConstructorOptions<TProperties>['ievents'];
|
|
218
|
+
useSelfSettings?: boolean;
|
|
219
|
+
[extensibleProperty: string]: any;
|
|
220
|
+
}
|
|
221
|
+
export interface Hooks<TThis = FxOrmInstance.Instance> {
|
|
222
|
+
beforeValidation?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
223
|
+
afterValidation?: FxOrmCommon.Arraible<FxOrmHook.HookRetPayloadCallback<TThis, {
|
|
224
|
+
errors: FxOrmError.ExtendedError[];
|
|
225
|
+
setErrors: (errors: FxOrmError.ExtendedError[]) => void;
|
|
226
|
+
}>>;
|
|
227
|
+
beforeCreate?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
228
|
+
afterCreate?: FxOrmCommon.Arraible<FxOrmHook.HookResultCallback<TThis>>;
|
|
229
|
+
beforeSave?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
230
|
+
afterSave?: FxOrmCommon.Arraible<FxOrmHook.HookResultCallback<TThis>>;
|
|
231
|
+
afterLoad?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
232
|
+
afterAutoFetch?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
233
|
+
beforeRemove?: FxOrmCommon.Arraible<FxOrmHook.HookActionCallback<TThis>>;
|
|
234
|
+
afterRemove?: FxOrmCommon.Arraible<FxOrmHook.HookResultCallback<TThis>>;
|
|
235
|
+
}
|
|
236
|
+
type __Item<T extends any> = T extends (infer U)[] ? U : T;
|
|
237
|
+
export interface ModelHookPatchOptions extends FxOrmHook.HookPatchOptions {
|
|
238
|
+
}
|
|
239
|
+
export interface ModelHooksModifier {
|
|
240
|
+
beforeValidation?: (func: __Item<Hooks['beforeValidation']>, opts?: ModelHookPatchOptions) => any;
|
|
241
|
+
afterValidation?: (func: __Item<Hooks['afterValidation']>, opts?: ModelHookPatchOptions) => void;
|
|
242
|
+
beforeCreate?: (func: __Item<Hooks['beforeCreate']>, opts?: ModelHookPatchOptions) => any;
|
|
243
|
+
afterCreate?: (func: __Item<Hooks['afterCreate']>, opts?: ModelHookPatchOptions) => any;
|
|
244
|
+
beforeSave?: (func: __Item<Hooks['beforeSave']>, opts?: ModelHookPatchOptions) => any;
|
|
245
|
+
afterSave?: (func: __Item<Hooks['afterSave']>, opts?: ModelHookPatchOptions) => any;
|
|
246
|
+
afterLoad?: (func: __Item<Hooks['afterLoad']>, opts?: ModelHookPatchOptions) => any;
|
|
247
|
+
afterAutoFetch?: (func: __Item<Hooks['afterAutoFetch']>, opts?: ModelHookPatchOptions) => any;
|
|
248
|
+
beforeRemove?: (func: __Item<Hooks['beforeRemove']>, opts?: ModelHookPatchOptions) => any;
|
|
249
|
+
afterRemove?: (func: __Item<Hooks['afterRemove']>, opts?: ModelHookPatchOptions) => any;
|
|
250
|
+
}
|
|
251
|
+
export interface ModelPropertyDefinition extends FxOrmProperty.DataStoreProperty {
|
|
252
|
+
key?: boolean;
|
|
253
|
+
klass?: FxOrmProperty.KlassType;
|
|
254
|
+
alwaysValidate?: boolean;
|
|
255
|
+
enumerable?: boolean;
|
|
256
|
+
lazyload?: boolean;
|
|
257
|
+
}
|
|
258
|
+
export type PrimitiveConstructor = StringConstructor | BooleanConstructor | NumberConstructor | DateConstructor | ObjectConstructor;
|
|
259
|
+
export type ComplexModelPropertyDefinition = ModelPropertyDefinition | (PrimitiveConstructor & {
|
|
260
|
+
name?: string;
|
|
261
|
+
}) | [...(string | number)[]] | (FxOrmProperty.NormalizedProperty['type']);
|
|
262
|
+
export type GetPrimitiveFromConstructor<T extends PrimitiveConstructor = PrimitiveConstructor> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? number | Date : T extends ObjectConstructor | typeof Class_Buffer ? any : never;
|
|
263
|
+
type GlobalModelType = FxOrmProperty.GlobalCustomModelType & {
|
|
264
|
+
[P in FxOrmProperty.PropertyType]: FxOrmProperty.GetPrimitiveFromOrmPropertyType<P>;
|
|
265
|
+
};
|
|
266
|
+
export type GetPropertiesTypeFromDefinition<T extends ComplexModelPropertyDefinition> = T extends keyof GlobalModelType ? GlobalModelType[T] : T extends [...infer S] ? S[number] : T extends ModelPropertyDefinition ? T['type'] extends 'enum' ? Exclude<T['values'], void>[number] : (T['type'] extends keyof GlobalModelType ? GlobalModelType[T['type']] : unknown) : T extends PrimitiveConstructor ? GetPrimitiveFromConstructor<T> : unknown;
|
|
267
|
+
export type GetPropertiesType<T extends Record<string, ComplexModelPropertyDefinition>> = {
|
|
268
|
+
[K in keyof T]: FxOrmModel.GetPropertiesTypeFromDefinition<T[K]>;
|
|
269
|
+
};
|
|
270
|
+
export interface ModelOptions__Find {
|
|
271
|
+
only?: string[];
|
|
272
|
+
limit?: number;
|
|
273
|
+
order?: FxOrmQuery.OrderRawInput | FxOrmQuery.ChainFindOptions['order'];
|
|
274
|
+
offset?: number;
|
|
275
|
+
identityCache?: boolean;
|
|
276
|
+
autoFetch?: boolean;
|
|
277
|
+
cascadeRemove?: boolean;
|
|
278
|
+
autoSave?: boolean;
|
|
279
|
+
autoFetchLimit?: number;
|
|
280
|
+
/** @internal */
|
|
281
|
+
__merge?: FxOrmQuery.ChainFindOptions['merge'];
|
|
282
|
+
/** @internal */
|
|
283
|
+
chainfind_linktable?: string;
|
|
284
|
+
/** @internal */
|
|
285
|
+
exists?: [FxOrmQuery.ChainWhereExistsInfo];
|
|
286
|
+
/**
|
|
287
|
+
* @description extra fields on find, e.g. from hasMany extra properties
|
|
288
|
+
*/
|
|
289
|
+
extra?: FxOrmAssociation.InstanceAssociationItem_HasMany['props'];
|
|
290
|
+
[k: string]: any;
|
|
291
|
+
}
|
|
292
|
+
export interface ModelOptions__Findby extends ModelOptions__Find {
|
|
293
|
+
}
|
|
294
|
+
export interface ModelOptions__Get extends ModelOptions__Find {
|
|
295
|
+
}
|
|
296
|
+
/** @deprecated use `FxOrmQuery.QueryConditions__Find` directly */
|
|
297
|
+
export type ModelQueryConditions__Find = FxOrmQuery.QueryConditions__Find;
|
|
298
|
+
export type ModelMethodOptions_Find = FxOrmCommon.IdType | FxOrmQuery.QueryConditions__Find;
|
|
299
|
+
export type ModelMethodCallback__Boolean = FxOrmCommon.GenericCallback<Boolean>;
|
|
300
|
+
export type ModelMethodCallback__Find = FxOrmCommon.GenericCallback<FxOrmInstance.Instance[]>;
|
|
301
|
+
export type ModelMethodCallback__Get = FxOrmCommon.GenericCallback<FxOrmInstance.Instance>;
|
|
302
|
+
export type ModelMethodCallback__CreateItem = FxOrmCommon.GenericCallback<FxOrmInstance.Instance>;
|
|
303
|
+
export type ModelMethodCallback__UpdateItem = FxOrmCommon.GenericCallback<FxOrmInstance.Instance>;
|
|
304
|
+
export type ModelMethodCallback__BatchCreate = FxOrmCommon.GenericCallback<FxOrmInstance.Instance[]>;
|
|
305
|
+
export type ModelMethodCallback__BatchUpdate = FxOrmCommon.GenericCallback<FxOrmInstance.Instance[]>;
|
|
306
|
+
export type ModelMethodCallback__Count = FxOrmCommon.GenericCallback<number>;
|
|
307
|
+
export interface ModelOptions__Create {
|
|
308
|
+
parallel?: boolean;
|
|
309
|
+
}
|
|
310
|
+
export {};
|
|
311
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare namespace FxOrmPatch {
|
|
2
|
+
interface PatchedSyncfiedModelOrInstance {
|
|
3
|
+
/**
|
|
4
|
+
* @important
|
|
5
|
+
*
|
|
6
|
+
* methods patchSyncfied by 'fib-orm'
|
|
7
|
+
*/
|
|
8
|
+
countSync: Function;
|
|
9
|
+
firstSync: Function;
|
|
10
|
+
lastSync: Function;
|
|
11
|
+
allSync: Function;
|
|
12
|
+
whereSync: Function;
|
|
13
|
+
findSync: Function;
|
|
14
|
+
removeSync: Function;
|
|
15
|
+
runSync: Function;
|
|
16
|
+
}
|
|
17
|
+
interface PatchedSyncfiedInstanceWithDbWriteOperation extends PatchedSyncfiedModelOrInstance {
|
|
18
|
+
saveSync: Function;
|
|
19
|
+
removeSync: Function;
|
|
20
|
+
validateSync: Function;
|
|
21
|
+
modelSync: Function;
|
|
22
|
+
}
|
|
23
|
+
interface PatchedSyncfiedInstanceWithAssociations {
|
|
24
|
+
/**
|
|
25
|
+
* generated by association, but you don't know what it is
|
|
26
|
+
*/
|
|
27
|
+
[associationFunc: string]: Function;
|
|
28
|
+
}
|
|
29
|
+
interface PatchedSyncfiedInstantce extends FxOrmPatch.PatchedSyncfiedInstanceWithDbWriteOperation, FxOrmPatch.PatchedSyncfiedInstanceWithAssociations {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { FxOrmSqlDDLSync__Driver } from "../../sql-ddl-sync/index";
|
|
2
|
+
import type { FxSqlQuery } from '../../sql-query/Query';
|
|
3
|
+
import type { IProperty } from "../../orm-property/index";
|
|
4
|
+
export declare namespace FxOrmProperty {
|
|
5
|
+
/**
|
|
6
|
+
* @description key linked association type
|
|
7
|
+
* - 'primary': means this property is for column defined as 'primary'
|
|
8
|
+
* - 'hasOne': means this property is for column used as asscociated key in 'hasOne' assciation
|
|
9
|
+
* - 'extendsTo': means this property is for column used as asscociated key in 'extendsTo' assciation
|
|
10
|
+
*/
|
|
11
|
+
type KlassType = 'primary' | 'hasOne' | 'extendsTo';
|
|
12
|
+
interface CustomPropertyType extends FxOrmSqlDDLSync__Driver.CustomPropertyType {
|
|
13
|
+
datastoreType: {
|
|
14
|
+
(prop?: FxOrmProperty.NormalizedProperty): string;
|
|
15
|
+
};
|
|
16
|
+
valueToProperty?: {
|
|
17
|
+
(value?: any, prop?: FxOrmProperty.NormalizedProperty): any;
|
|
18
|
+
};
|
|
19
|
+
propertyToValue?: {
|
|
20
|
+
(value?: any, prop?: FxOrmProperty.NormalizedProperty): any;
|
|
21
|
+
};
|
|
22
|
+
datastoreGet?: {
|
|
23
|
+
(prop?: FxOrmProperty.NormalizedProperty, helper?: FxSqlQuery.Class_Query): any;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
type DataStoreProperty = IProperty & {
|
|
27
|
+
type: PropertyType | keyof GlobalCustomModelType;
|
|
28
|
+
/**
|
|
29
|
+
* @description virtual property is not stored in database,
|
|
30
|
+
* but maybe presented in query result
|
|
31
|
+
*/
|
|
32
|
+
virtual?: boolean;
|
|
33
|
+
};
|
|
34
|
+
type PropertyType = 'text' | 'integer' | 'number' | 'serial' | 'boolean' | 'date' | 'binary' | 'object' | 'enum' | 'point';
|
|
35
|
+
/**
|
|
36
|
+
* @description used for augumenting model's properties type
|
|
37
|
+
*/
|
|
38
|
+
interface GlobalCustomModelType {
|
|
39
|
+
}
|
|
40
|
+
type GetPrimitiveFromOrmPropertyType<T extends PropertyType = PropertyType> = T extends 'text' ? string : T extends 'enum' ? any[] : T extends 'integer' | 'number' | 'serial' ? number : T extends 'boolean' ? boolean : T extends 'date' ? number | Date : T extends 'binary' | 'object' | 'point' ? any : never;
|
|
41
|
+
/**
|
|
42
|
+
* @description useful when pass property's option(such as type, big, ...etc) internally, useless for exposed api.
|
|
43
|
+
*
|
|
44
|
+
* @notice though there's definition, but those fields SHOULD NEVER be set in NormalizedProperty:
|
|
45
|
+
* - `serial`
|
|
46
|
+
*/
|
|
47
|
+
interface NormalizedProperty extends DataStoreProperty {
|
|
48
|
+
key?: boolean;
|
|
49
|
+
klass?: KlassType;
|
|
50
|
+
lazyload?: boolean;
|
|
51
|
+
alwaysValidate?: boolean;
|
|
52
|
+
lazyname?: string;
|
|
53
|
+
}
|
|
54
|
+
interface FieldToPropertyMapType {
|
|
55
|
+
[f_name: string]: NormalizedProperty;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import type { FxOrmAssociation } from './assoc';
|
|
2
|
+
import type { FxOrmDb } from './Db';
|
|
3
|
+
import type { FxOrmDMLDriver } from './DMLDriver';
|
|
4
|
+
import type { FxOrmInstance } from './instance';
|
|
5
|
+
import type { FxOrmModel } from './model';
|
|
6
|
+
import type { FxOrmProperty } from './property';
|
|
7
|
+
import type { FxOrmCommon } from './_common';
|
|
8
|
+
import type { FxSqlQueryColumns, FxSqlQueryComparator, FxSqlQuerySubQuery, FxSqlQuery, FxSqlQuerySql } from '../../sql-query/Query';
|
|
9
|
+
export declare namespace FxOrmQuery {
|
|
10
|
+
type QueryConditionInTypeType = string | number;
|
|
11
|
+
type QueryCondition_SimpleEq = {
|
|
12
|
+
[key: string]: FxSqlQueryComparator.SimpleEqValueType;
|
|
13
|
+
};
|
|
14
|
+
type QueryCondition_eq = {
|
|
15
|
+
[key: string]: FxSqlQueryComparator.SimpleEqValueType | FxSqlQueryComparator.InputValue_eq;
|
|
16
|
+
};
|
|
17
|
+
type QueryCondition_ne = {
|
|
18
|
+
[key: string]: FxSqlQueryComparator.InputValue_ne;
|
|
19
|
+
};
|
|
20
|
+
type QueryCondition_gt = {
|
|
21
|
+
[key: string]: FxSqlQueryComparator.InputValue_gt;
|
|
22
|
+
};
|
|
23
|
+
type QueryCondition_gte = {
|
|
24
|
+
[key: string]: FxSqlQueryComparator.InputValue_gte;
|
|
25
|
+
};
|
|
26
|
+
type QueryCondition_lt = {
|
|
27
|
+
[key: string]: FxSqlQueryComparator.InputValue_lt;
|
|
28
|
+
};
|
|
29
|
+
type QueryCondition_lte = {
|
|
30
|
+
[key: string]: FxSqlQueryComparator.InputValue_lte;
|
|
31
|
+
};
|
|
32
|
+
type QueryCondition_like = {
|
|
33
|
+
[key: string]: FxSqlQueryComparator.InputValue_like;
|
|
34
|
+
};
|
|
35
|
+
type QueryCondition_not_like = {
|
|
36
|
+
[key: string]: FxSqlQueryComparator.InputValue_not_like;
|
|
37
|
+
};
|
|
38
|
+
type QueryCondition_between = {
|
|
39
|
+
[key: string]: FxSqlQueryComparator.InputValue_between;
|
|
40
|
+
};
|
|
41
|
+
type QueryCondition_not_between = {
|
|
42
|
+
[key: string]: FxSqlQueryComparator.InputValue_not_between;
|
|
43
|
+
};
|
|
44
|
+
type QueryCondition_in = {
|
|
45
|
+
[key: string]: FxSqlQueryComparator.InputValue_in;
|
|
46
|
+
};
|
|
47
|
+
type QueryCondition_not_in = {
|
|
48
|
+
[key: string]: FxSqlQueryComparator.InputValue_not_in;
|
|
49
|
+
};
|
|
50
|
+
type QueryConditionAtomicType = QueryCondition_eq | QueryCondition_ne | QueryCondition_gt | QueryCondition_gte | QueryCondition_lt | QueryCondition_lte | QueryCondition_like | QueryCondition_not_like | QueryCondition_between | QueryCondition_not_between | QueryCondition_in | QueryCondition_not_in;
|
|
51
|
+
type QueryConditions = FxSqlQuerySubQuery.SubQueryConditions;
|
|
52
|
+
type QueryConditionsItem = FxSqlQuerySql.SqlFragmentStr | FxOrmQuery.QueryConditions__Find;
|
|
53
|
+
type OrderNormalizedTuple = FxSqlQuery.OrderNormalizedTuple;
|
|
54
|
+
type OrderSqlStyleTuple = FxSqlQuery.OrderSqlStyleTuple;
|
|
55
|
+
type OrderNormalizedResult = FxSqlQuery.OrderNormalizedResult;
|
|
56
|
+
type OrderSeqRawTuple = (OrderNormalizedTupleWithoutTable[0] | OrderNormalizedTupleWithoutTable[1])[];
|
|
57
|
+
type OrderRawInput = string | OrderSeqRawTuple;
|
|
58
|
+
type OrderNormalizedTupleWithoutTable = [string, "Z" | "A"];
|
|
59
|
+
type OrderNormalizedTupleMixin = (OrderNormalizedTupleWithoutTable | FxSqlQuery.OrderNormalizedResult)[];
|
|
60
|
+
interface QueryConditions__Find extends FxSqlQuerySubQuery.SubQueryConditions {
|
|
61
|
+
[property: string]: any;
|
|
62
|
+
}
|
|
63
|
+
interface ChainFindMergeInfo {
|
|
64
|
+
from: {
|
|
65
|
+
table: string;
|
|
66
|
+
field: string[];
|
|
67
|
+
};
|
|
68
|
+
to: {
|
|
69
|
+
table?: string;
|
|
70
|
+
field: string[];
|
|
71
|
+
};
|
|
72
|
+
select: FxSqlQueryColumns.SelectInputArgType[];
|
|
73
|
+
where: [string, QueryConditions__Find];
|
|
74
|
+
table: string;
|
|
75
|
+
}
|
|
76
|
+
interface ChainWhereExistsInfo {
|
|
77
|
+
table: string;
|
|
78
|
+
link: FxSqlQuerySql.WhereExistsLinkTuple;
|
|
79
|
+
conditions: FxSqlQuerySubQuery.SubQueryConditions;
|
|
80
|
+
}
|
|
81
|
+
interface InsertResult {
|
|
82
|
+
insertId?: string | number;
|
|
83
|
+
[extra_key: string]: any;
|
|
84
|
+
}
|
|
85
|
+
interface CountResult {
|
|
86
|
+
c: number;
|
|
87
|
+
[extra_key: string]: any;
|
|
88
|
+
}
|
|
89
|
+
interface RemoveResult {
|
|
90
|
+
[extra_key: string]: any;
|
|
91
|
+
}
|
|
92
|
+
interface AggregationMethod {
|
|
93
|
+
(...args: string[]): IAggregated;
|
|
94
|
+
(arg: string[]): IAggregated;
|
|
95
|
+
}
|
|
96
|
+
interface IAggregated {
|
|
97
|
+
groupBy: {
|
|
98
|
+
(...columns: string[]): IAggregated;
|
|
99
|
+
};
|
|
100
|
+
limit: {
|
|
101
|
+
(limit: number): IAggregated;
|
|
102
|
+
(offset: number, limit: number): IAggregated;
|
|
103
|
+
};
|
|
104
|
+
order: {
|
|
105
|
+
(...order: string[]): IAggregated;
|
|
106
|
+
};
|
|
107
|
+
select: {
|
|
108
|
+
(columns: string[]): IAggregated;
|
|
109
|
+
(...columns: string[]): IAggregated;
|
|
110
|
+
};
|
|
111
|
+
as: {
|
|
112
|
+
(alias: string): IAggregated;
|
|
113
|
+
};
|
|
114
|
+
call: {
|
|
115
|
+
(fun: FxOrmDb.AGGREGATION_METHOD_COMPLEX, args: string[]): IAggregated;
|
|
116
|
+
};
|
|
117
|
+
getSync: {
|
|
118
|
+
<T = any>(): FxOrmCommon.ExecutionCallback<T[]>;
|
|
119
|
+
};
|
|
120
|
+
get: {
|
|
121
|
+
<T = any>(cb?: FxOrmCommon.ExecutionCallback<T[]>): void;
|
|
122
|
+
};
|
|
123
|
+
[ext_k: string]: any;
|
|
124
|
+
}
|
|
125
|
+
type KeyOfIAggregated = keyof IAggregated;
|
|
126
|
+
type AggregationFuncTuple = FxOrmDb.AGGREGATION_METHOD_TUPLE__COMMON;
|
|
127
|
+
interface SqlSelectFieldsDescriptor extends FxSqlQuerySql.SqlSelectFieldItemDescriptor {
|
|
128
|
+
args?: string | string[];
|
|
129
|
+
}
|
|
130
|
+
interface AggregateConstructorOptions {
|
|
131
|
+
driver: FxOrmDMLDriver.DMLDriver;
|
|
132
|
+
driver_name?: string;
|
|
133
|
+
limit?: [number, number];
|
|
134
|
+
order?: FxOrmQuery.ChainFindOptions['order'];
|
|
135
|
+
propertyList?: string[];
|
|
136
|
+
table?: string;
|
|
137
|
+
conditions?: FxOrmQuery.QueryConditions;
|
|
138
|
+
properties: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
139
|
+
}
|
|
140
|
+
type AggregateConstructor = new (opts: AggregateConstructorOptions) => IAggregated;
|
|
141
|
+
type ChainFindGenerator = new (Model: FxOrmModel.Model, opts: FxOrmQuery.ChainFindOptions) => IChainFind;
|
|
142
|
+
interface IChainFind<HP extends Record<string, FxOrmInstance.FieldRuntimeType> = Record<string, FxOrmInstance.FieldRuntimeType>, HM extends Record<string, (...args: any) => any> = Record<string, (...args: any) => any>> {
|
|
143
|
+
model: FxOrmModel.Model<HP, HM>;
|
|
144
|
+
options: ChainFindInstanceOptions;
|
|
145
|
+
only(...args: (string | string[])[]): this;
|
|
146
|
+
omit(...args: (string | string[])[]): this;
|
|
147
|
+
skip(offset: number): this;
|
|
148
|
+
offset(offset: number): this;
|
|
149
|
+
order(propertyOrderDesc: string, order?: FxOrmQuery.OrderNormalizedTuple[1]): this;
|
|
150
|
+
order(...orders: FxOrmQuery.OrderSeqRawTuple): this;
|
|
151
|
+
orderRaw(str: FxOrmQuery.OrderSqlStyleTuple[0], args?: FxOrmQuery.OrderSqlStyleTuple[1]): this;
|
|
152
|
+
limit(limit: number): this;
|
|
153
|
+
count(callback?: FxOrmCommon.ExecutionCallback<number>): this;
|
|
154
|
+
countSync(): number;
|
|
155
|
+
remove(callback?: FxOrmCommon.ExecutionCallback<FxOrmQuery.RemoveResult>): this;
|
|
156
|
+
removeSync(): FxOrmQuery.RemoveResult;
|
|
157
|
+
find<T = FxOrmInstance.Instance<HP, HM>[]>(...conditions: (FxOrmQuery.QueryConditionsItem | FxOrmCommon.ExecutionCallback<T>)[]): this;
|
|
158
|
+
findSync: {
|
|
159
|
+
<T = FxOrmInstance.Instance<HP, HM>[]>(...conditions: (FxOrmQuery.QueryConditionsItem | FxOrmCommon.ExecutionCallback<T>)[]): T;
|
|
160
|
+
};
|
|
161
|
+
all: this['find'];
|
|
162
|
+
allSync: this['findSync'];
|
|
163
|
+
where: this['find'];
|
|
164
|
+
whereSync: this['findSync'];
|
|
165
|
+
whereExists(...exists: FxOrmQuery.ChainWhereExistsInfo[]): this;
|
|
166
|
+
whereExists(exists: FxOrmQuery.ChainWhereExistsInfo[]): this;
|
|
167
|
+
run(callback?: FxOrmQuery.IChainInstanceCallbackFn): this;
|
|
168
|
+
runSync<T = FxOrmInstance.Instance<HP, HM>[]>(): T;
|
|
169
|
+
first(callback?: FxOrmCommon.GenericCallback<FxOrmInstance.Instance<HP, HM> | null>): this;
|
|
170
|
+
firstSync(): FxOrmInstance.Instance<HP, HM> | null;
|
|
171
|
+
last(callback?: FxOrmCommon.GenericCallback<FxOrmInstance.Instance<HP, HM> | null>): this;
|
|
172
|
+
lastSync(): FxOrmInstance.Instance<HP, HM> | null;
|
|
173
|
+
each: {
|
|
174
|
+
<T = FxOrmInstance.Instance<HP, HM>>(cb?: FxOrmCommon.ExecutionCallback<T>): IChainInstance;
|
|
175
|
+
};
|
|
176
|
+
eager(...assocs: string[]): this;
|
|
177
|
+
eager(assocs: string[]): this;
|
|
178
|
+
[extraProperty: string]: any;
|
|
179
|
+
}
|
|
180
|
+
interface IChainInstanceCallbackFn {
|
|
181
|
+
(...args: any[]): any | FxOrmQuery.IChainInstance;
|
|
182
|
+
}
|
|
183
|
+
interface IChainInstance {
|
|
184
|
+
_each(cb: IChainInstanceCallbackFn): IChainInstance;
|
|
185
|
+
filter(cb: IChainInstanceCallbackFn): IChainInstance;
|
|
186
|
+
sort(cb: IChainInstanceCallbackFn): IChainInstance;
|
|
187
|
+
count(cb: IChainInstanceCallbackFn): IChainInstance;
|
|
188
|
+
get(cb: IChainInstanceCallbackFn): IChainInstance;
|
|
189
|
+
save(cb: IChainInstanceCallbackFn): IChainInstance;
|
|
190
|
+
}
|
|
191
|
+
interface ChainFindOptions {
|
|
192
|
+
keys: string[];
|
|
193
|
+
table: string;
|
|
194
|
+
generateSqlSelect?: FxOrmDMLDriver.DMLDriver_FindOptions['generateSqlSelect'];
|
|
195
|
+
driver: FxOrmDMLDriver.DMLDriver;
|
|
196
|
+
conditions: QueryConditions;
|
|
197
|
+
/**
|
|
198
|
+
* @notice virtual properties included here
|
|
199
|
+
*/
|
|
200
|
+
properties: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
201
|
+
keyProperties: FxOrmProperty.NormalizedProperty[];
|
|
202
|
+
order: (FxOrmQuery.OrderNormalizedTuple | FxOrmQuery.OrderSqlStyleTuple)[];
|
|
203
|
+
only: (string | FxSqlQueryColumns.SelectInputArgType)[];
|
|
204
|
+
limit: number;
|
|
205
|
+
offset: number;
|
|
206
|
+
merge: FxOrmQuery.ChainFindMergeInfo | FxOrmQuery.ChainFindMergeInfo[];
|
|
207
|
+
newInstanceSync: {
|
|
208
|
+
(data: FxOrmInstance.InstanceDataPayload): FxOrmInstance.Instance;
|
|
209
|
+
};
|
|
210
|
+
associations: FxOrmAssociation.InstanceAssociationItem[];
|
|
211
|
+
exists?: FxOrmQuery.ChainWhereExistsInfo[];
|
|
212
|
+
__eager?: FxOrmAssociation.InstanceAssociationItem[];
|
|
213
|
+
}
|
|
214
|
+
interface ChainFindInstanceOptions extends ChainFindOptions {
|
|
215
|
+
}
|
|
216
|
+
}
|