mythix-orm 1.5.6 → 1.6.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/lib/connection/connection-base.d.ts +180 -0
- package/lib/connection/connection-base.js +242 -16
- package/lib/connection/index.d.ts +5 -0
- package/lib/connection/literals/average-literal.d.ts +5 -0
- package/lib/connection/literals/count-literal.d.ts +5 -0
- package/lib/connection/literals/distinct-literal.d.ts +5 -0
- package/lib/connection/literals/field-literal.d.ts +5 -0
- package/lib/connection/literals/index.d.ts +10 -0
- package/lib/connection/literals/literal-base.d.ts +22 -0
- package/lib/connection/literals/literal-base.js +2 -2
- package/lib/connection/literals/literal-field-base.d.ts +17 -0
- package/lib/connection/literals/literal-field-base.js +4 -4
- package/lib/connection/literals/literal.d.ts +5 -0
- package/lib/connection/literals/max-literal.d.ts +5 -0
- package/lib/connection/literals/min-literal.d.ts +5 -0
- package/lib/connection/literals/sum-literal.d.ts +5 -0
- package/lib/connection/query-generator-base.d.ts +121 -0
- package/lib/connection/query-generator-base.js +5 -6
- package/lib/field.d.ts +61 -0
- package/lib/field.js +9 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +7 -1
- package/lib/interfaces/common.ts +3 -0
- package/lib/model.d.ts +205 -0
- package/lib/model.js +136 -32
- package/lib/proxy-class/proxy-class.js +6 -6
- package/lib/query-engine/index.d.ts +1 -0
- package/lib/query-engine/model-scope.js +2 -2
- package/lib/query-engine/query-engine-base.js +2 -2
- package/lib/query-engine/query-engine.d.ts +144 -0
- package/lib/query-engine/query-engine.js +4 -0
- package/lib/types/concrete/bigint-type.d.ts +16 -0
- package/lib/types/concrete/bigint-type.js +8 -5
- package/lib/types/concrete/blob-type.d.ts +11 -0
- package/lib/types/concrete/blob-type.js +5 -4
- package/lib/types/concrete/boolean-type.d.ts +11 -0
- package/lib/types/concrete/boolean-type.js +4 -4
- package/lib/types/concrete/char-type.d.ts +11 -0
- package/lib/types/concrete/char-type.js +4 -4
- package/lib/types/concrete/date-type.d.ts +16 -0
- package/lib/types/concrete/date-type.js +9 -4
- package/lib/types/concrete/datetime-type.d.ts +16 -0
- package/lib/types/concrete/datetime-type.js +9 -4
- package/lib/types/concrete/foreign-key-type.d.ts +32 -0
- package/lib/types/concrete/foreign-key-type.js +274 -10
- package/lib/types/concrete/index.d.ts +19 -0
- package/lib/types/concrete/index.js +2 -0
- package/lib/types/concrete/integer-type.d.ts +16 -0
- package/lib/types/concrete/integer-type.js +6 -4
- package/lib/types/concrete/numeric-type.d.ts +11 -0
- package/lib/types/concrete/numeric-type.js +6 -4
- package/lib/types/concrete/real-type.d.ts +11 -0
- package/lib/types/concrete/real-type.js +111 -4
- package/lib/types/concrete/serialized-type.d.ts +25 -0
- package/lib/types/concrete/serialized-type.js +287 -5
- package/lib/types/concrete/string-type.d.ts +11 -0
- package/lib/types/concrete/string-type.js +0 -4
- package/lib/types/concrete/text-type.d.ts +11 -0
- package/lib/types/concrete/text-type.js +0 -4
- package/lib/types/concrete/uuid-base.d.ts +13 -0
- package/lib/types/concrete/uuid-base.js +4 -1
- package/lib/types/concrete/uuid-v1-type.d.ts +31 -0
- package/lib/types/concrete/uuid-v1-type.js +0 -4
- package/lib/types/concrete/uuid-v3-type.d.ts +27 -0
- package/lib/types/concrete/uuid-v3-type.js +0 -4
- package/lib/types/concrete/uuid-v4-type.d.ts +27 -0
- package/lib/types/concrete/uuid-v4-type.js +0 -4
- package/lib/types/concrete/uuid-v5-type.d.ts +27 -0
- package/lib/types/concrete/uuid-v5-type.js +0 -4
- package/lib/types/concrete/xid-type.d.ts +17 -0
- package/lib/types/concrete/xid-type.js +0 -4
- package/lib/types/helpers/default-helpers.d.ts +61 -0
- package/lib/types/helpers/index.d.ts +1 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +2 -0
- package/lib/types/type.d.ts +89 -0
- package/lib/types/type.js +57 -25
- package/lib/types/virtual/index.d.ts +4 -0
- package/lib/types/virtual/model-type.d.ts +15 -0
- package/lib/types/virtual/model-type.js +2 -2
- package/lib/types/virtual/models-type.d.ts +15 -0
- package/lib/types/virtual/models-type.js +5 -5
- package/lib/types/virtual/relational-type-base.d.ts +46 -0
- package/lib/types/virtual/relational-type-base.js +12 -20
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +1 -4
- package/lib/utils/misc-utils.d.ts +4 -0
- package/lib/utils/misc-utils.js +0 -35
- package/lib/utils/model-utils.d.ts +90 -0
- package/lib/utils/model-utils.js +4 -4
- package/lib/utils/query-utils.d.ts +11 -0
- package/package.json +3 -2
- package/.biblorc.js +0 -29
- package/docs/Associations.md +0 -539
- package/docs/Certifications.md +0 -22
- package/docs/Home.md +0 -54
- package/docs/Query Engine.md +0 -428
|
@@ -65,7 +65,7 @@ class ProxyClass {
|
|
|
65
65
|
Object.defineProperties(func, {
|
|
66
66
|
[AUTO_CALL]: {
|
|
67
67
|
writable: true,
|
|
68
|
-
|
|
68
|
+
enumerable: false,
|
|
69
69
|
configurable: true,
|
|
70
70
|
value: true,
|
|
71
71
|
},
|
|
@@ -151,19 +151,19 @@ class ProxyClass {
|
|
|
151
151
|
Object.defineProperties(me, {
|
|
152
152
|
[PROXY]: {
|
|
153
153
|
writable: true,
|
|
154
|
-
|
|
154
|
+
enumerable: false,
|
|
155
155
|
configurable: true,
|
|
156
156
|
value: proxy,
|
|
157
157
|
},
|
|
158
158
|
[TARGET]: {
|
|
159
159
|
writable: true,
|
|
160
|
-
|
|
160
|
+
enumerable: false,
|
|
161
161
|
configurable: true,
|
|
162
162
|
value: proxyTarget,
|
|
163
163
|
},
|
|
164
164
|
[SELF]: {
|
|
165
165
|
writable: true,
|
|
166
|
-
|
|
166
|
+
enumerable: false,
|
|
167
167
|
configurable: true,
|
|
168
168
|
value: me,
|
|
169
169
|
},
|
|
@@ -176,13 +176,13 @@ class ProxyClass {
|
|
|
176
176
|
Object.defineProperties(this, {
|
|
177
177
|
[AUTO_CALL_CALLER]: {
|
|
178
178
|
writable: true,
|
|
179
|
-
|
|
179
|
+
enumerable: false,
|
|
180
180
|
configurable: true,
|
|
181
181
|
value: null,
|
|
182
182
|
},
|
|
183
183
|
[AUTO_CALL_CALLED]: {
|
|
184
184
|
writable: true,
|
|
185
|
-
|
|
185
|
+
enumerable: false,
|
|
186
186
|
configurable: true,
|
|
187
187
|
value: false,
|
|
188
188
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './query-engine';
|
|
@@ -180,8 +180,8 @@ class ModelScope extends QueryEngineBase {
|
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
JOIN(type) {
|
|
183
|
-
if (
|
|
184
|
-
throw new Error('QueryEngine::ModelScope::JOIN: Invalid value provided. Value must be a valid string specifying JOIN type.');
|
|
183
|
+
if (!(Nife.instanceOf(type, 'string') || LiteralBase.isLiteral(type)))
|
|
184
|
+
throw new Error('QueryEngine::ModelScope::JOIN: Invalid value provided. Value must be a valid string or Literal specifying JOIN type.');
|
|
185
185
|
|
|
186
186
|
this._addToQuery({ control: true, operator: 'JOIN', value: type, joinType: type, joinOuter: false });
|
|
187
187
|
return this._fetchScope('model');
|
|
@@ -208,12 +208,12 @@ class QueryEngineBase extends ProxyClass {
|
|
|
208
208
|
Object.defineProperties(this, {
|
|
209
209
|
queryRoot: {
|
|
210
210
|
writable: false,
|
|
211
|
-
|
|
211
|
+
enumerable: false,
|
|
212
212
|
configurable: true,
|
|
213
213
|
value: queryRoot,
|
|
214
214
|
},
|
|
215
215
|
currentContext: {
|
|
216
|
-
|
|
216
|
+
enumerable: false,
|
|
217
217
|
configurable: true,
|
|
218
218
|
get: () => {
|
|
219
219
|
let currentContext = queryRoot[queryRoot.length - 1];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import ConnectionBase from '../connection/connection-base';
|
|
2
|
+
import { LiteralBase } from '../connection/literals';
|
|
3
|
+
import { GenericObject } from '../interfaces/common';
|
|
4
|
+
import { Model, ModelClass } from '../model';
|
|
5
|
+
import Field from '../field';
|
|
6
|
+
|
|
7
|
+
export declare interface QueryEngineOptions {
|
|
8
|
+
connection: ConnectionBase;
|
|
9
|
+
[ key: string ]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export declare type QueryEngineClass = typeof QueryEngine;
|
|
13
|
+
|
|
14
|
+
export declare interface CallableInterface {
|
|
15
|
+
(...args: Array<any>): QueryEngine;
|
|
16
|
+
[ key: string ]: QueryEngine;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare class QueryEngine<T = ConnectionBase> {
|
|
20
|
+
// QueryEngineBase
|
|
21
|
+
static generateID(): number;
|
|
22
|
+
static isQueryContext(value: any): boolean;
|
|
23
|
+
static isQuery(value: any): boolean;
|
|
24
|
+
static queryContextType(queryContext: GenericObject): { hasCondition: boolean; hasField: boolean; hasModel: boolean; };
|
|
25
|
+
|
|
26
|
+
public getModelScopeClass(): QueryEngine;
|
|
27
|
+
public getFieldScopeClass(): QueryEngine;
|
|
28
|
+
public _inheritContext(context: GenericObject, name: string, ...args: Array<GenericObject>): GenericObject;
|
|
29
|
+
public _fetchScope(...scopeNames: Array<string>): QueryEngine;
|
|
30
|
+
public _newQueryEngineScope(): QueryEngine;
|
|
31
|
+
public _newModelScope(Model: ModelClass): QueryEngine;
|
|
32
|
+
public _newFieldScope(Field: Field): QueryEngine;
|
|
33
|
+
public constructor(context: QueryEngineOptions);
|
|
34
|
+
public _getTopContextID(): number;
|
|
35
|
+
public _getRawQueryContext(): GenericObject;
|
|
36
|
+
public _getRawQuery(): Array<GenericObject>;
|
|
37
|
+
public _isLastPartControl(): boolean;
|
|
38
|
+
public _isLastPartCondition(): boolean;
|
|
39
|
+
public _queryHasConditions(): boolean;
|
|
40
|
+
public _queryHasJoins(): boolean;
|
|
41
|
+
public _debugQuery(): void;
|
|
42
|
+
public _addToQuery(queryPart: GenericObject, context: GenericObject): void;
|
|
43
|
+
public getConnection(): ConnectionBase;
|
|
44
|
+
public getModel(modelName: string): ModelClass | undefined;
|
|
45
|
+
public getQueryEngineScope(): QueryEngine;
|
|
46
|
+
public getQueryEngineClass(): QueryEngineClass;
|
|
47
|
+
public clone(): QueryEngine;
|
|
48
|
+
|
|
49
|
+
// QueryEngine
|
|
50
|
+
public getModelScopeClass(): QueryEngineClass;
|
|
51
|
+
public getFieldScopeClass(): QueryEngineClass;
|
|
52
|
+
public Model(modelName: string): QueryEngine;
|
|
53
|
+
public unscoped(context?: GenericObject): QueryEngine;
|
|
54
|
+
public toString(options?: GenericObject): string;
|
|
55
|
+
public MERGE(queryEngine: QueryEngine): QueryEngine;
|
|
56
|
+
public all(options?: GenericObject): Promise<Array<Model>>;
|
|
57
|
+
public fetchAll(options?: GenericObject): AsyncGenerator<Model>;
|
|
58
|
+
public first(limit?: number | null | undefined, options?: GenericObject): Promise<Model | undefined>;
|
|
59
|
+
public last(limit?: number | null | undefined, options?: GenericObject): Promise<Model | undefined>;
|
|
60
|
+
public update(attributes: Model | GenericObject, options?: GenericObject): Promise<number>;
|
|
61
|
+
public destroy(options?: GenericObject): Promise<number>;
|
|
62
|
+
public average(field: Field | string, options?: GenericObject): Promise<number>;
|
|
63
|
+
public count(field: Field | string, options?: GenericObject): Promise<number>;
|
|
64
|
+
public min(field: Field | string, options?: GenericObject): Promise<number>;
|
|
65
|
+
public max(field: Field | string, options?: GenericObject): Promise<number>;
|
|
66
|
+
public sum(field: Field | string, options?: GenericObject): Promise<number>;
|
|
67
|
+
public pluck(fields: string | Array<string>, options?: GenericObject): Promise<Array<any>>;
|
|
68
|
+
public exists(options?: GenericObject): Promise<boolean>;
|
|
69
|
+
|
|
70
|
+
// ModelScope
|
|
71
|
+
public _getField(fieldName: string): Field | undefined;
|
|
72
|
+
public _getQueryEngineClass(): QueryEngineClass;
|
|
73
|
+
public Field(fieldName: string): QueryEngine;
|
|
74
|
+
public LIMIT(value: number): QueryEngine;
|
|
75
|
+
public OFFSET(value: number): QueryEngine;
|
|
76
|
+
public ORDER(...args: Array<string | Array<string>>): QueryEngine;
|
|
77
|
+
public PROJECT(...args: Array<string | ModelClass | LiteralBase | Field>): QueryEngine;
|
|
78
|
+
|
|
79
|
+
declare public NOT: {
|
|
80
|
+
(): QueryEngine;
|
|
81
|
+
[ key: string ]: QueryEngine;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
declare public AND: {
|
|
85
|
+
(query: QueryEngine): QueryEngine;
|
|
86
|
+
[ key: string ]: QueryEngine;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare public OR: {
|
|
90
|
+
(query: QueryEngine): QueryEngine;
|
|
91
|
+
[ key: string ]: QueryEngine;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
declare public DISTINCT: {
|
|
95
|
+
(fullyQualifiedName: string | Field): QueryEngine;
|
|
96
|
+
[ key: string ]: QueryEngine;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
declare public INNER_JOIN: {
|
|
100
|
+
(): QueryEngine;
|
|
101
|
+
[ key: string ]: QueryEngine;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
declare public LEFT_JOIN: {
|
|
105
|
+
(): QueryEngine;
|
|
106
|
+
[ key: string ]: QueryEngine;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare public RIGHT_JOIN: {
|
|
110
|
+
(): QueryEngine;
|
|
111
|
+
[ key: string ]: QueryEngine;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
declare public FULL_JOIN: {
|
|
115
|
+
(): QueryEngine;
|
|
116
|
+
[ key: string ]: QueryEngine;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
declare public CROSS_JOIN: {
|
|
120
|
+
(): QueryEngine;
|
|
121
|
+
[ key: string ]: QueryEngine;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
declare public JOIN: {
|
|
125
|
+
(type: string | LiteralBase): QueryEngine;
|
|
126
|
+
[ key: string ]: QueryEngine;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// FieldScope
|
|
130
|
+
public _fetchOperatorValue(value: any): any;
|
|
131
|
+
public EQ(value: any): QueryEngine;
|
|
132
|
+
public NEQ(value: any): QueryEngine;
|
|
133
|
+
public GT(value: any): QueryEngine;
|
|
134
|
+
public GTE(value: any): QueryEngine;
|
|
135
|
+
public LT(value: any): QueryEngine;
|
|
136
|
+
public LTE(value: any): QueryEngine;
|
|
137
|
+
public LIKE(value: string, options?: { caseSensitive: boolean }): QueryEngine;
|
|
138
|
+
public NOT_LIKE(value: string, options?: { caseSensitive: boolean }): QueryEngine;
|
|
139
|
+
|
|
140
|
+
[ key: string ]: any;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class ModelScope extends QueryEngine { }
|
|
144
|
+
export class FieldScope extends QueryEngine { }
|
|
@@ -134,6 +134,10 @@ class QueryEngine extends QueryEngineBase {
|
|
|
134
134
|
return Utils.collect(connection.select(this, options));
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
fetchAll(options) {
|
|
138
|
+
return this.all({ ...(options || {}), stream: true });
|
|
139
|
+
}
|
|
140
|
+
|
|
137
141
|
async first(_limit, options) {
|
|
138
142
|
let limit = (_limit == null) ? 1 : _limit;
|
|
139
143
|
let connection = this.getConnection(options && options.connection);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AutoIncrementDefaultValueProvider } from '../helpers/default-helpers';
|
|
2
|
+
import Type, { TypeWrapper } from '../type';
|
|
3
|
+
|
|
4
|
+
export declare interface BigIntTypeWrapper extends TypeWrapper<BigIntType> {
|
|
5
|
+
(length?: number, options?: { strict: boolean }): BigIntType;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare class BigIntType extends Type {
|
|
9
|
+
declare public static Default: {
|
|
10
|
+
AUTO_INCREMENT: AutoIncrementDefaultValueProvider;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
public constructor(length?: number, options?: { strict: boolean });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const BIGINT: BigIntTypeWrapper;
|
|
@@ -39,10 +39,12 @@ const { AUTO_INCREMENT } = require('../helpers/default-helpers');
|
|
|
39
39
|
/// Mythix ORM supports emulation of BIGINT auto-incrementing
|
|
40
40
|
/// IDs in its [mythix-orm-sqlite](https://www.npmjs.com/package/mythix-orm-sqlite)
|
|
41
41
|
/// driver. You can read more about it in the documentation.
|
|
42
|
+
///
|
|
42
43
|
/// Properties:
|
|
43
44
|
/// Default: object = { AUTO_INCREMENT }
|
|
44
45
|
/// `AUTO_INCREMENT` is a method that can be used as the `defaultValue` of a <see>Field</see>
|
|
45
46
|
/// to have this field auto-increment in the underlying database.
|
|
47
|
+
///
|
|
46
48
|
/// See: Type
|
|
47
49
|
class BigIntType extends Type {
|
|
48
50
|
static Default = {
|
|
@@ -57,16 +59,13 @@ class BigIntType extends Type {
|
|
|
57
59
|
/// Note:
|
|
58
60
|
/// This is also an instance method that can be called from
|
|
59
61
|
/// an instance of the type.
|
|
62
|
+
///
|
|
60
63
|
/// Return: string
|
|
61
64
|
/// Return the string value `'BIGINT'`
|
|
62
65
|
static getDisplayName() {
|
|
63
66
|
return 'BIGINT';
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
getDisplayName() {
|
|
67
|
-
return this.constructor.getDisplayName();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
69
|
/// Construct a new `BIGINT` type.
|
|
71
70
|
///
|
|
72
71
|
/// The `length` argument--as on all
|
|
@@ -85,6 +84,7 @@ class BigIntType extends Type {
|
|
|
85
84
|
/// as a `number` primitive.
|
|
86
85
|
///
|
|
87
86
|
/// Return: BigIntType
|
|
87
|
+
///
|
|
88
88
|
/// Arguments:
|
|
89
89
|
/// length?: number = 8
|
|
90
90
|
/// How many bytes to use in the underlying database to store the value.
|
|
@@ -102,7 +102,7 @@ class BigIntType extends Type {
|
|
|
102
102
|
Object.defineProperties(this, {
|
|
103
103
|
'_options': {
|
|
104
104
|
writable: true,
|
|
105
|
-
|
|
105
|
+
enumerable: false,
|
|
106
106
|
configurable: true,
|
|
107
107
|
value: options,
|
|
108
108
|
},
|
|
@@ -124,6 +124,7 @@ class BigIntType extends Type {
|
|
|
124
124
|
/// Return the incoming `value`, cast to this
|
|
125
125
|
/// type. `null` and `undefined` are simply
|
|
126
126
|
/// returned without casting.
|
|
127
|
+
///
|
|
127
128
|
/// Arguments:
|
|
128
129
|
/// context: <see name="CastToTypeContext">Type.castToType</see>
|
|
129
130
|
castToType({ value }) {
|
|
@@ -145,6 +146,7 @@ class BigIntType extends Type {
|
|
|
145
146
|
/// then it will return `true`.
|
|
146
147
|
///
|
|
147
148
|
/// Return: boolean
|
|
149
|
+
///
|
|
148
150
|
/// Arguments:
|
|
149
151
|
/// value: any
|
|
150
152
|
/// The value to check.
|
|
@@ -164,6 +166,7 @@ class BigIntType extends Type {
|
|
|
164
166
|
/// the type.
|
|
165
167
|
///
|
|
166
168
|
/// Return: string
|
|
169
|
+
///
|
|
167
170
|
/// Arguments:
|
|
168
171
|
/// connection?: <see>Connection</see>
|
|
169
172
|
/// An optional connection. If provided, send this
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Type, { TypeWrapper } from '../type';
|
|
2
|
+
|
|
3
|
+
export declare interface BlobTypeWrapper extends TypeWrapper<BlobType> {
|
|
4
|
+
(length: number): BlobType;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare class BlobType extends Type {
|
|
8
|
+
public constructor(length: number);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const BLOB: BlobTypeWrapper;
|
|
@@ -32,16 +32,13 @@ class BlobType extends Type {
|
|
|
32
32
|
/// Note:
|
|
33
33
|
/// This is also an instance method that can be called from
|
|
34
34
|
/// an instance of the type.
|
|
35
|
+
///
|
|
35
36
|
/// Return: string
|
|
36
37
|
/// Return the string value `'BLOB'`
|
|
37
38
|
static getDisplayName() {
|
|
38
39
|
return 'BLOB';
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
getDisplayName() {
|
|
42
|
-
return this.constructor.getDisplayName();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
42
|
/// Construct a new `BLOB` type.
|
|
46
43
|
///
|
|
47
44
|
/// The `length` argument is the number
|
|
@@ -49,6 +46,7 @@ class BlobType extends Type {
|
|
|
49
46
|
/// store the data.
|
|
50
47
|
///
|
|
51
48
|
/// Return: BlobType
|
|
49
|
+
///
|
|
52
50
|
/// Arguments:
|
|
53
51
|
/// length?: number
|
|
54
52
|
/// How many bytes to use in the underlying database to store the value.
|
|
@@ -74,6 +72,7 @@ class BlobType extends Type {
|
|
|
74
72
|
/// Return the incoming `value`, cast to this
|
|
75
73
|
/// type. `null` and `undefined` are simply
|
|
76
74
|
/// returned without casting.
|
|
75
|
+
///
|
|
77
76
|
/// Arguments:
|
|
78
77
|
/// context: <see name="CastToTypeContext">Type.castToType</see>
|
|
79
78
|
castToType({ value }) {
|
|
@@ -93,6 +92,7 @@ class BlobType extends Type {
|
|
|
93
92
|
/// otherwise it will return `false`.
|
|
94
93
|
///
|
|
95
94
|
/// Return: boolean
|
|
95
|
+
///
|
|
96
96
|
/// Arguments:
|
|
97
97
|
/// value: any
|
|
98
98
|
/// The value to check.
|
|
@@ -110,6 +110,7 @@ class BlobType extends Type {
|
|
|
110
110
|
/// when no `connection` is provided is `'BLOB'`.
|
|
111
111
|
///
|
|
112
112
|
/// Return: string
|
|
113
|
+
///
|
|
113
114
|
/// Arguments:
|
|
114
115
|
/// connection?: <see>Connection</see>
|
|
115
116
|
/// An optional connection. If provided, send this
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Type, { TypeWrapper } from '../type';
|
|
2
|
+
|
|
3
|
+
export declare interface BooleanTypeWrapper extends TypeWrapper<BooleanType> {
|
|
4
|
+
(): BooleanType;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare class BooleanType extends Type {
|
|
8
|
+
public constructor();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const BOOLEAN: BooleanTypeWrapper;
|
|
@@ -24,16 +24,13 @@ class BooleanType extends Type {
|
|
|
24
24
|
/// Note:
|
|
25
25
|
/// This is also an instance method that can be called from
|
|
26
26
|
/// an instance of the type.
|
|
27
|
+
///
|
|
27
28
|
/// Return: string
|
|
28
29
|
/// Return the string value `'BOOLEAN'`
|
|
29
30
|
static getDisplayName() {
|
|
30
31
|
return 'BOOLEAN';
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
getDisplayName() {
|
|
34
|
-
return this.constructor.getDisplayName();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
34
|
/// Cast provided value to underlying type.
|
|
38
35
|
///
|
|
39
36
|
/// This will cast the incoming value to the
|
|
@@ -53,6 +50,7 @@ class BooleanType extends Type {
|
|
|
53
50
|
/// Return the incoming `value`, cast to this
|
|
54
51
|
/// type. `null` and `undefined` are simply
|
|
55
52
|
/// returned without casting.
|
|
53
|
+
///
|
|
56
54
|
/// Arguments:
|
|
57
55
|
/// context: <see name="CastToTypeContext">Type.castToType</see>
|
|
58
56
|
castToType({ value }) {
|
|
@@ -76,6 +74,7 @@ class BooleanType extends Type {
|
|
|
76
74
|
/// will return `true`, otherwise it will return `false`.
|
|
77
75
|
///
|
|
78
76
|
/// Return: boolean
|
|
77
|
+
///
|
|
79
78
|
/// Arguments:
|
|
80
79
|
/// value: any
|
|
81
80
|
/// The value to check.
|
|
@@ -93,6 +92,7 @@ class BooleanType extends Type {
|
|
|
93
92
|
/// when no `connection` is provided is `'BOOLEAN'`.
|
|
94
93
|
///
|
|
95
94
|
/// Return: string
|
|
95
|
+
///
|
|
96
96
|
/// Arguments:
|
|
97
97
|
/// connection?: <see>Connection</see>
|
|
98
98
|
/// An optional connection. If provided, send this
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Type, { TypeWrapper } from '../type';
|
|
2
|
+
|
|
3
|
+
export declare interface CharTypeWrapper extends TypeWrapper<CharType> {
|
|
4
|
+
(): CharType;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare class CharType extends Type {
|
|
8
|
+
public constructor();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const CHAR: CharTypeWrapper;
|
|
@@ -26,16 +26,13 @@ class CharType extends Type {
|
|
|
26
26
|
/// Note:
|
|
27
27
|
/// This is also an instance method that can be called from
|
|
28
28
|
/// an instance of the type.
|
|
29
|
+
///
|
|
29
30
|
/// Return: string
|
|
30
31
|
/// Return the string value `'CHAR'`
|
|
31
32
|
static getDisplayName() {
|
|
32
33
|
return 'CHAR';
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
getDisplayName() {
|
|
36
|
-
return this.constructor.getDisplayName();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
36
|
/// Cast provided value to underlying type.
|
|
40
37
|
///
|
|
41
38
|
/// This will cast the incoming value to the
|
|
@@ -53,6 +50,7 @@ class CharType extends Type {
|
|
|
53
50
|
/// Return the incoming `value`, cast to this
|
|
54
51
|
/// type. `null` and `undefined` are simply
|
|
55
52
|
/// returned without casting.
|
|
53
|
+
///
|
|
56
54
|
/// Arguments:
|
|
57
55
|
/// context: <see name="CastToTypeContext">Type.castToType</see>
|
|
58
56
|
castToType({ value }) {
|
|
@@ -73,6 +71,7 @@ class CharType extends Type {
|
|
|
73
71
|
/// return `true`, otherwise it will return `false`.
|
|
74
72
|
///
|
|
75
73
|
/// Return: boolean
|
|
74
|
+
///
|
|
76
75
|
/// Arguments:
|
|
77
76
|
/// value: any
|
|
78
77
|
/// The value to check.
|
|
@@ -90,6 +89,7 @@ class CharType extends Type {
|
|
|
90
89
|
/// when no `connection` is provided is `'CHAR'`.
|
|
91
90
|
///
|
|
92
91
|
/// Return: string
|
|
92
|
+
///
|
|
93
93
|
/// Arguments:
|
|
94
94
|
/// connection?: <see>Connection</see>
|
|
95
95
|
/// An optional connection. If provided, send this
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UpdateDefaultValueProvider } from '../helpers/default-helpers';
|
|
2
|
+
import Type, { TypeWrapper } from '../type';
|
|
3
|
+
|
|
4
|
+
export declare interface DateTypeWrapper extends TypeWrapper<DateType, UpdateDefaultValueProvider> {
|
|
5
|
+
(format?: string): DateType;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare class DateType extends Type {
|
|
9
|
+
declare public static Default: {
|
|
10
|
+
NOW: UpdateDefaultValueProvider;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
public constructor(format?: string);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const DATE: DateTypeWrapper;
|
|
@@ -41,6 +41,7 @@ moment.suppressDeprecationWarnings = true;
|
|
|
41
41
|
/// 3. `Types.DATE.Default.NOW.LOCAL` = Local (client-side) 'NOW' time, set on insert only.<br>
|
|
42
42
|
/// 4. `Types.DATE.Default.NOW.LOCAL.UPDATE` = Local (client-side) 'NOW' time, set on insert and update.<br>
|
|
43
43
|
/// *Note: It is highly recommended that you **do not** use `LOCAL` time unless you know exactly what you are doing, as clock-drift between machines may become an issue.*
|
|
44
|
+
///
|
|
44
45
|
/// See: Type
|
|
45
46
|
class DateType extends Type {
|
|
46
47
|
static Default = {
|
|
@@ -55,16 +56,13 @@ class DateType extends Type {
|
|
|
55
56
|
/// Note:
|
|
56
57
|
/// This is also an instance method that can be called from
|
|
57
58
|
/// an instance of the type.
|
|
59
|
+
///
|
|
58
60
|
/// Return: string
|
|
59
61
|
/// Return the string value `'DATE'`
|
|
60
62
|
static getDisplayName() {
|
|
61
63
|
return 'DATE';
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
getDisplayName() {
|
|
65
|
-
return this.constructor.getDisplayName();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
66
|
/// Construct a new `DATE` type.
|
|
69
67
|
///
|
|
70
68
|
/// The `format` argument will specify the
|
|
@@ -79,6 +77,7 @@ class DateType extends Type {
|
|
|
79
77
|
/// when calling <see>Model.toJSON</see>.
|
|
80
78
|
///
|
|
81
79
|
/// Return: DateType
|
|
80
|
+
///
|
|
82
81
|
/// Arguments:
|
|
83
82
|
/// format?: string
|
|
84
83
|
/// Specify the client-side formatting for this date field.
|
|
@@ -109,6 +108,7 @@ class DateType extends Type {
|
|
|
109
108
|
/// Return the incoming `value`, cast to this
|
|
110
109
|
/// type. `null` and `undefined` are simply
|
|
111
110
|
/// returned without casting.
|
|
111
|
+
///
|
|
112
112
|
/// Arguments:
|
|
113
113
|
/// context: <see name="CastToTypeContext">Type.castToType</see>
|
|
114
114
|
castToType({ value, connection }) {
|
|
@@ -133,6 +133,7 @@ class DateType extends Type {
|
|
|
133
133
|
/// See the [moment](https://momentjs.com/docs/) library documentation for more information.
|
|
134
134
|
///
|
|
135
135
|
/// Return: boolean
|
|
136
|
+
///
|
|
136
137
|
/// Arguments:
|
|
137
138
|
/// value: any
|
|
138
139
|
/// The value to check.
|
|
@@ -150,6 +151,7 @@ class DateType extends Type {
|
|
|
150
151
|
/// when no `connection` is provided is `'DATE'`.
|
|
151
152
|
///
|
|
152
153
|
/// Return: string
|
|
154
|
+
///
|
|
153
155
|
/// Arguments:
|
|
154
156
|
/// connection?: <see>Connection</see>
|
|
155
157
|
/// An optional connection. If provided, send this
|
|
@@ -180,6 +182,7 @@ class DateType extends Type {
|
|
|
180
182
|
/// to [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
|
181
183
|
///
|
|
182
184
|
/// Return: string | null | undefined
|
|
185
|
+
///
|
|
183
186
|
/// Arguments:
|
|
184
187
|
/// value: moment
|
|
185
188
|
/// The date value to serialize.
|
|
@@ -218,7 +221,9 @@ class DateType extends Type {
|
|
|
218
221
|
/// Note:
|
|
219
222
|
/// This method is called by `castToType` to cast
|
|
220
223
|
/// incoming values into `moment` instances.
|
|
224
|
+
///
|
|
221
225
|
/// Return: moment
|
|
226
|
+
///
|
|
222
227
|
/// Arguments:
|
|
223
228
|
/// value: string | moment | null | undefined
|
|
224
229
|
/// The value to deserialize.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UpdateDefaultValueProvider } from '../helpers/default-helpers';
|
|
2
|
+
import Type, { TypeWrapper } from '../type';
|
|
3
|
+
|
|
4
|
+
export declare interface DateTimeTypeWrapper extends TypeWrapper<DateTimeType, UpdateDefaultValueProvider> {
|
|
5
|
+
(format?: string, length?: number): DateTimeType;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare class DateTimeType extends Type {
|
|
9
|
+
declare public static Default: {
|
|
10
|
+
NOW: UpdateDefaultValueProvider;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
public constructor(format?: string, length?: number);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const DATETIME: DateTimeTypeWrapper;
|
|
@@ -41,6 +41,7 @@ moment.suppressDeprecationWarnings = true;
|
|
|
41
41
|
/// 3. `Types.DATETIME.Default.NOW.LOCAL` = Local (client-side) 'NOW' time, set on insert only.<br>
|
|
42
42
|
/// 4. `Types.DATETIME.Default.NOW.LOCAL.UPDATE` = Local (client-side) 'NOW' time, set on insert and update.<br>
|
|
43
43
|
/// *Note: It is highly recommended that you **do not** use `LOCAL` time unless you know exactly what you are doing, as clock-drift between machines may become an issue.*
|
|
44
|
+
///
|
|
44
45
|
/// See: Type
|
|
45
46
|
class DateTimeType extends Type {
|
|
46
47
|
static Default = {
|
|
@@ -55,16 +56,13 @@ class DateTimeType extends Type {
|
|
|
55
56
|
/// Note:
|
|
56
57
|
/// This is also an instance method that can be called from
|
|
57
58
|
/// an instance of the type.
|
|
59
|
+
///
|
|
58
60
|
/// Return: string
|
|
59
61
|
/// Return the string value `'DATETIME'`
|
|
60
62
|
static getDisplayName() {
|
|
61
63
|
return 'DATETIME';
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
getDisplayName() {
|
|
65
|
-
return this.constructor.getDisplayName();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
66
|
/// Construct a new `DATETIME` type.
|
|
69
67
|
///
|
|
70
68
|
/// The `format` argument will specify the
|
|
@@ -82,6 +80,7 @@ class DateTimeType extends Type {
|
|
|
82
80
|
/// to modify the precision of the underlying timestamp/datetime value.
|
|
83
81
|
///
|
|
84
82
|
/// Return: DateTimeType
|
|
83
|
+
///
|
|
85
84
|
/// Arguments:
|
|
86
85
|
/// format?: string
|
|
87
86
|
/// Specify the client-side formatting for this date field.
|
|
@@ -111,6 +110,7 @@ class DateTimeType extends Type {
|
|
|
111
110
|
/// Return the incoming `value`, cast to this
|
|
112
111
|
/// type. `null` and `undefined` are simply
|
|
113
112
|
/// returned without casting.
|
|
113
|
+
///
|
|
114
114
|
/// Arguments:
|
|
115
115
|
/// context: <see name="CastToTypeContext">Type.castToType</see>
|
|
116
116
|
castToType({ value, connection }) {
|
|
@@ -135,6 +135,7 @@ class DateTimeType extends Type {
|
|
|
135
135
|
/// See the [moment](https://momentjs.com/docs/) library documentation for more information.
|
|
136
136
|
///
|
|
137
137
|
/// Return: boolean
|
|
138
|
+
///
|
|
138
139
|
/// Arguments:
|
|
139
140
|
/// value: any
|
|
140
141
|
/// The value to check.
|
|
@@ -152,6 +153,7 @@ class DateTimeType extends Type {
|
|
|
152
153
|
/// when no `connection` is provided is `'DATETIME'`.
|
|
153
154
|
///
|
|
154
155
|
/// Return: string
|
|
156
|
+
///
|
|
155
157
|
/// Arguments:
|
|
156
158
|
/// connection?: <see>Connection</see>
|
|
157
159
|
/// An optional connection. If provided, send this
|
|
@@ -182,6 +184,7 @@ class DateTimeType extends Type {
|
|
|
182
184
|
/// to [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
|
183
185
|
///
|
|
184
186
|
/// Return: string | null | undefined
|
|
187
|
+
///
|
|
185
188
|
/// Arguments:
|
|
186
189
|
/// value: moment
|
|
187
190
|
/// The date value to serialize.
|
|
@@ -224,7 +227,9 @@ class DateTimeType extends Type {
|
|
|
224
227
|
/// Note:
|
|
225
228
|
/// This method is called by `castToType` to cast
|
|
226
229
|
/// incoming values into `moment` instances.
|
|
230
|
+
///
|
|
227
231
|
/// Return: moment
|
|
232
|
+
///
|
|
228
233
|
/// Arguments:
|
|
229
234
|
/// value: string | moment | null | undefined
|
|
230
235
|
/// The value to deserialize.
|