mythix-orm 1.5.5 → 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.
Files changed (100) hide show
  1. package/lib/connection/connection-base.d.ts +180 -0
  2. package/lib/connection/connection-base.js +272 -16
  3. package/lib/connection/index.d.ts +5 -0
  4. package/lib/connection/literals/average-literal.d.ts +5 -0
  5. package/lib/connection/literals/count-literal.d.ts +5 -0
  6. package/lib/connection/literals/distinct-literal.d.ts +5 -0
  7. package/lib/connection/literals/field-literal.d.ts +5 -0
  8. package/lib/connection/literals/field-literal.js +14 -0
  9. package/lib/connection/literals/index.d.ts +10 -0
  10. package/lib/connection/literals/index.js +15 -13
  11. package/lib/connection/literals/literal-base.d.ts +22 -0
  12. package/lib/connection/literals/literal-base.js +2 -2
  13. package/lib/connection/literals/literal-field-base.d.ts +17 -0
  14. package/lib/connection/literals/literal-field-base.js +4 -4
  15. package/lib/connection/literals/literal.d.ts +5 -0
  16. package/lib/connection/literals/max-literal.d.ts +5 -0
  17. package/lib/connection/literals/min-literal.d.ts +5 -0
  18. package/lib/connection/literals/sum-literal.d.ts +5 -0
  19. package/lib/connection/query-generator-base.d.ts +121 -0
  20. package/lib/connection/query-generator-base.js +32 -26
  21. package/lib/field.d.ts +61 -0
  22. package/lib/field.js +9 -0
  23. package/lib/index.d.ts +7 -0
  24. package/lib/index.js +7 -1
  25. package/lib/interfaces/common.ts +3 -0
  26. package/lib/model.d.ts +205 -0
  27. package/lib/model.js +136 -32
  28. package/lib/proxy-class/proxy-class.js +6 -6
  29. package/lib/query-engine/field-scope.js +1 -0
  30. package/lib/query-engine/index.d.ts +1 -0
  31. package/lib/query-engine/model-scope.js +2 -2
  32. package/lib/query-engine/query-engine-base.js +18 -2
  33. package/lib/query-engine/query-engine.d.ts +144 -0
  34. package/lib/query-engine/query-engine.js +4 -0
  35. package/lib/types/concrete/bigint-type.d.ts +16 -0
  36. package/lib/types/concrete/bigint-type.js +8 -5
  37. package/lib/types/concrete/blob-type.d.ts +11 -0
  38. package/lib/types/concrete/blob-type.js +5 -4
  39. package/lib/types/concrete/boolean-type.d.ts +11 -0
  40. package/lib/types/concrete/boolean-type.js +4 -4
  41. package/lib/types/concrete/char-type.d.ts +11 -0
  42. package/lib/types/concrete/char-type.js +4 -4
  43. package/lib/types/concrete/date-type.d.ts +16 -0
  44. package/lib/types/concrete/date-type.js +9 -4
  45. package/lib/types/concrete/datetime-type.d.ts +16 -0
  46. package/lib/types/concrete/datetime-type.js +9 -4
  47. package/lib/types/concrete/foreign-key-type.d.ts +32 -0
  48. package/lib/types/concrete/foreign-key-type.js +274 -10
  49. package/lib/types/concrete/index.d.ts +19 -0
  50. package/lib/types/concrete/index.js +2 -0
  51. package/lib/types/concrete/integer-type.d.ts +16 -0
  52. package/lib/types/concrete/integer-type.js +6 -4
  53. package/lib/types/concrete/numeric-type.d.ts +11 -0
  54. package/lib/types/concrete/numeric-type.js +6 -4
  55. package/lib/types/concrete/real-type.d.ts +11 -0
  56. package/lib/types/concrete/real-type.js +111 -4
  57. package/lib/types/concrete/serialized-type.d.ts +25 -0
  58. package/lib/types/concrete/serialized-type.js +287 -5
  59. package/lib/types/concrete/string-type.d.ts +11 -0
  60. package/lib/types/concrete/string-type.js +0 -4
  61. package/lib/types/concrete/text-type.d.ts +11 -0
  62. package/lib/types/concrete/text-type.js +0 -4
  63. package/lib/types/concrete/uuid-base.d.ts +13 -0
  64. package/lib/types/concrete/uuid-base.js +4 -1
  65. package/lib/types/concrete/uuid-v1-type.d.ts +31 -0
  66. package/lib/types/concrete/uuid-v1-type.js +0 -4
  67. package/lib/types/concrete/uuid-v3-type.d.ts +27 -0
  68. package/lib/types/concrete/uuid-v3-type.js +0 -4
  69. package/lib/types/concrete/uuid-v4-type.d.ts +27 -0
  70. package/lib/types/concrete/uuid-v4-type.js +0 -4
  71. package/lib/types/concrete/uuid-v5-type.d.ts +27 -0
  72. package/lib/types/concrete/uuid-v5-type.js +0 -4
  73. package/lib/types/concrete/xid-type.d.ts +17 -0
  74. package/lib/types/concrete/xid-type.js +0 -4
  75. package/lib/types/helpers/default-helpers.d.ts +61 -0
  76. package/lib/types/helpers/index.d.ts +1 -0
  77. package/lib/types/index.d.ts +6 -0
  78. package/lib/types/index.js +2 -0
  79. package/lib/types/type.d.ts +89 -0
  80. package/lib/types/type.js +57 -25
  81. package/lib/types/virtual/index.d.ts +4 -0
  82. package/lib/types/virtual/model-type.d.ts +15 -0
  83. package/lib/types/virtual/model-type.js +2 -2
  84. package/lib/types/virtual/models-type.d.ts +15 -0
  85. package/lib/types/virtual/models-type.js +5 -5
  86. package/lib/types/virtual/relational-type-base.d.ts +46 -0
  87. package/lib/types/virtual/relational-type-base.js +12 -20
  88. package/lib/utils/index.d.ts +6 -0
  89. package/lib/utils/index.js +1 -4
  90. package/lib/utils/misc-utils.d.ts +4 -0
  91. package/lib/utils/misc-utils.js +0 -35
  92. package/lib/utils/model-utils.d.ts +90 -0
  93. package/lib/utils/model-utils.js +4 -4
  94. package/lib/utils/query-utils.d.ts +11 -0
  95. package/package.json +3 -2
  96. package/.biblorc.js +0 -29
  97. package/docs/Associations.md +0 -539
  98. package/docs/Certifications.md +0 -22
  99. package/docs/Home.md +0 -54
  100. package/docs/Query Engine.md +0 -428
@@ -0,0 +1,22 @@
1
+ import Field from '../../field';
2
+ import { GenericObject } from '../../interfaces/common';
3
+ import { FullyQualifiedFieldDefinition } from '../../utils/model-utils';
4
+ import ConnectionBase from '../connection-base';
5
+
6
+ declare class LiteralBase {
7
+ declare public static _isMythixLiteral: boolean;
8
+
9
+ public static isLiteralClass(value: any): boolean;
10
+ public static isLiteral(value: any): boolean;
11
+ public static isLiteralType(value: any): boolean;
12
+
13
+ public constructor(literal: any, options?: GenericObject);
14
+ public fullyQualifiedNameToDefinition(fullyQualifiedName: LiteralBase | string | Field): LiteralBase | FullyQualifiedFieldDefinition;
15
+ public definitionToField(connection, definition): LiteralBase | Field;
16
+ public toString(connection: ConnectionBase, options?: GenericObject): string;
17
+
18
+ declare public literal: any;
19
+ declare public options: GenericObject;
20
+ }
21
+
22
+ export default LiteralBase;
@@ -39,13 +39,13 @@ class LiteralBase {
39
39
  Object.defineProperties(this, {
40
40
  'literal': {
41
41
  writable: true,
42
- enumberable: false,
42
+ enumerable: false,
43
43
  configurable: true,
44
44
  value: literal,
45
45
  },
46
46
  'options': {
47
47
  writable: true,
48
- enumberable: false,
48
+ enumerable: false,
49
49
  configurable: true,
50
50
  value: options || {},
51
51
  },
@@ -0,0 +1,17 @@
1
+ import Field from '../../field';
2
+ import { GenericObject } from '../../interfaces/common';
3
+ import { FullyQualifiedFieldDefinition } from '../../utils/model-utils';
4
+ import ConnectionBase from '../connection-base';
5
+ import LiteralBase from './literal-base';
6
+
7
+ declare class LiteralFieldBase extends LiteralBase {
8
+ public static isFieldRequired(): boolean;
9
+
10
+ public constructor(fullyQualifiedName: Field | string, options?: GenericObject);
11
+ getFullyQualifiedFieldName(): string | undefined;
12
+ getField(connection: ConnectionBase): Field | undefined;
13
+
14
+ declare public definition: FullyQualifiedFieldDefinition | undefined;
15
+ }
16
+
17
+ export default LiteralFieldBase;
@@ -8,8 +8,8 @@ class LiteralFieldBase extends LiteralBase {
8
8
  return true;
9
9
  }
10
10
 
11
- constructor(fullyQualifiedName) {
12
- super();
11
+ constructor(fullyQualifiedName, options) {
12
+ super(undefined, options);
13
13
 
14
14
  let isRequired = this.constructor.isFieldRequired();
15
15
  let definition;
@@ -26,7 +26,7 @@ class LiteralFieldBase extends LiteralBase {
26
26
  Object.defineProperties(this, {
27
27
  'definition': {
28
28
  writable: true,
29
- enumberable: false,
29
+ enumerable: false,
30
30
  configurable: true,
31
31
  value: definition,
32
32
  },
@@ -43,7 +43,7 @@ class LiteralFieldBase extends LiteralBase {
43
43
 
44
44
  getField(connection) {
45
45
  if (!this.definition)
46
- return null;
46
+ return;
47
47
 
48
48
  return this.definitionToField(connection, this.definition);
49
49
  }
@@ -0,0 +1,5 @@
1
+ import LiteralBase from './literal-base';
2
+
3
+ declare class Literal extends LiteralBase { }
4
+
5
+ export default Literal;
@@ -0,0 +1,5 @@
1
+ import LiteralFieldBase from './literal-field-base';
2
+
3
+ declare class MaxLiteral extends LiteralFieldBase { }
4
+
5
+ export default MaxLiteral;
@@ -0,0 +1,5 @@
1
+ import LiteralFieldBase from './literal-field-base';
2
+
3
+ declare class MinLiteral extends LiteralFieldBase { }
4
+
5
+ export default MinLiteral;
@@ -0,0 +1,5 @@
1
+ import LiteralFieldBase from './literal-field-base';
2
+
3
+ declare class SumLiteral extends LiteralFieldBase { }
4
+
5
+ export default SumLiteral;
@@ -0,0 +1,121 @@
1
+ import Field from '../field';
2
+ import { GenericObject } from '../interfaces/common';
3
+ import { ModelClass } from '../model';
4
+ import { QueryEngine } from '../query-engine';
5
+ import ConnectionBase from './connection-base';
6
+ import { AverageLiteral, CountLiteral, DistinctLiteral, FieldLiteral, MaxLiteral, MinLiteral, SumLiteral } from './literals';
7
+ import LiteralBase from './literals/literal-base';
8
+
9
+ export declare interface GetEscapedFieldNameOptions {
10
+ fieldNameOnly?: boolean;
11
+ }
12
+
13
+ export declare interface GetEscapedTableNameNameOptions {
14
+ tableNamePrefix?: string;
15
+ }
16
+
17
+ export declare interface GetEscapedColumnNameOptions extends GetEscapedTableNameNameOptions {
18
+ columnNamePrefix?: string
19
+ columnNameOnly?: boolean;
20
+ }
21
+
22
+ export declare interface GetEscapedProjectionNameOptions extends GetEscapedColumnNameOptions, GetEscapedFieldNameOptions {
23
+ noProjectionAliases?: boolean;
24
+ }
25
+
26
+ export declare interface GetEscapedModelFieldsOptions extends GetEscapedProjectionNameOptions {
27
+ asProjection?: boolean;
28
+ asColumn?: boolean;
29
+ }
30
+
31
+ export declare interface ProjectedFieldInfo {
32
+ projectedName: string;
33
+ Model: ModelClass;
34
+ modelName: string;
35
+ Field: Field;
36
+ fieldName: string;
37
+ direction: string;
38
+ fullFieldName: string;
39
+ }
40
+
41
+ export declare interface JoinTableInfo {
42
+ operator: string;
43
+ joinType: string | LiteralBase;
44
+ rootModelName: string;
45
+ joinModel: ModelClass;
46
+ joinModelName: string;
47
+ leftSideModel: ModelClass;
48
+ leftSideModelName: string;
49
+ leftQueryContext: GenericObject;
50
+ leftSideField: Field;
51
+ rightSideModel: ModelClass;
52
+ rightSideModelName: string;
53
+ rightQueryContext: GenericObject;
54
+ rightSideField: Field;
55
+ }
56
+
57
+ export declare interface FieldDirectionInfo {
58
+ hasDirection: boolean;
59
+ direction: string;
60
+ fieldName: string;
61
+ }
62
+
63
+ export declare interface FieldOrderInfo {
64
+ Model: ModelClass;
65
+ Field: Field;
66
+ direction: string;
67
+ }
68
+
69
+ declare class QueryGeneratorBase {
70
+ public constructor(connection);
71
+ public stackAssign(obj: GenericObject, ...args: Array<GenericObject>): GenericObject;
72
+ public getOptionsCache(options: GenericObject, keyPath: string, initialValue: any): any;
73
+ public setOptionsCache(options: GenericObject, keyPath: string, value: any): void;
74
+ public escape(field: Field, value: any, options?: GenericObject): string;
75
+ public escapeID(value: LiteralBase | string, options?: GenericObject): string;
76
+ public getEscapedFieldName(Model: ModelClass | null | undefined, field: Field, options?: GetEscapedFieldNameOptions): string;
77
+ public getEscapedColumnName(Model: ModelClass | null | undefined, field: Field, options?: GetEscapedColumnNameOptions): string;
78
+ public getEscapedTableName(modelOrField: ModelClass | Field, options?: GetEscapedTableNameNameOptions): string;
79
+ public getEscapedProjectionName(Model: ModelClass | null | undefined, field: Field, options?: GetEscapedProjectionNameOptions): string;
80
+ public getEscapedModelFields(Model: ModelClass, options?: GetEscapedModelFieldsOptions): { [ key: string ]: string };
81
+ public getAllModelsUsedInQuery(queryEngine: QueryEngine, options?: GenericObject): Array<ModelClass>;
82
+ public getProjectionRequiredFields(queryEngine: QueryEngine, options?: GenericObject): Map<string, ProjectedFieldInfo>;
83
+ public sortedProjectedFields(projectedFields: Array<LiteralBase | string>, options?: GenericObject): Array<LiteralBase | string>;
84
+ public getProjectionFromQueryEngine(queryEngine: QueryEngine, options?: GenericObject): Array<LiteralBase | string | ProjectedFieldInfo>;
85
+ public isFieldIdentifier(value: string): boolean;
86
+ public getProjectedFields(queryEngine: QueryEngine, options?: GenericObject, asMap?: false | undefined): Array<string>;
87
+ public getProjectedFields(queryEngine: QueryEngine, options?: GenericObject, asMap?: true): Map<string, string>;
88
+
89
+ public getJoinTableInfoFromQueryContexts(
90
+ leftQueryContext: GenericObject,
91
+ rightQueryContext: GenericObject,
92
+ joinType: string | LiteralBase,
93
+ options?: GenericObject
94
+ ): JoinTableInfo;
95
+
96
+ public getFieldDirectionSpecifier(order: LiteralBase): LiteralBase;
97
+ public getFieldDirectionSpecifier(order: string | Field): FieldDirectionInfo;
98
+
99
+ public getOrderLimitOffset(
100
+ queryEngine: QueryEngine,
101
+ options?: GenericObject,
102
+ ): {
103
+ limit: number | undefined,
104
+ offset: number | undefined,
105
+ order: Array<FieldOrderInfo>,
106
+ };
107
+
108
+ public getQuerySliceFromQueryPart(queryPart: GenericObject): Array<GenericObject>;
109
+ public _averageLiteralToString(literal: AverageLiteral, options?: GenericObject): string;
110
+ public _countLiteralToString(literal: CountLiteral, options?: GenericObject): string;
111
+ public _distinctLiteralToString(literal: DistinctLiteral, options?: GenericObject): string;
112
+ public _fieldLiteralToString(literal: FieldLiteral, options?: GenericObject): string;
113
+ public _maxLiteralToString(literal: MaxLiteral, options?: GenericObject): string;
114
+ public _minLiteralToString(literal: MinLiteral, options?: GenericObject): string;
115
+ public _sumLiteralToString(literal: SumLiteral, options?: GenericObject): string;
116
+ public toConnectionString(queryEngine: QueryEngine, options?: GenericObject): string;
117
+
118
+ declare public connection: ConnectionBase;
119
+ }
120
+
121
+ export default QueryGeneratorBase;
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const Nife = require('nife');
4
- const QueryEngine = require('../query-engine/query-engine');
5
- const Literals = require('./literals');
6
- const ModelBase = require('../model');
7
-
3
+ const Nife = require('nife');
4
+ const QueryEngine = require('../query-engine/query-engine');
5
+ const Literals = require('./literals');
6
+ const { Model: ModelBase } = require('../model');
8
7
  const LiteralBase = Literals.LiteralBase;
9
8
  const LITERAL_IS_DISTINCT_RE = (/^DISTINCT[\s(]/i);
10
9
 
@@ -13,7 +12,7 @@ class QueryGeneratorBase {
13
12
  Object.defineProperties(this, {
14
13
  'connection': {
15
14
  writable: true,
16
- enumberable: false,
15
+ enumerable: false,
17
16
  configurable: true,
18
17
  value: connection,
19
18
  },
@@ -46,11 +45,6 @@ class QueryGeneratorBase {
46
45
  return this.connection.escapeID(...args);
47
46
  }
48
47
 
49
- getTableNameFromQueryPart(queryPart) {
50
- let Model = queryPart.Model;
51
- return Model.getTableName(this.connection);
52
- }
53
-
54
48
  getEscapedFieldName(_Model, field, options) {
55
49
  let isString = Nife.instanceOf(field, 'string');
56
50
  let fieldName = (isString) ? field : field.fieldName;
@@ -73,10 +67,23 @@ class QueryGeneratorBase {
73
67
  if (!Model && field && !isString)
74
68
  Model = field.Model;
75
69
 
70
+ if (options && options.columnNamePrefix)
71
+ columnName = `${options.columnNamePrefix}${columnName}`;
72
+
76
73
  if (!Model || (options && options.columnNameOnly === true))
77
74
  return this.escapeID(columnName);
78
75
  else
79
- return `${this.escapeID(Model.getTableName(this.connection))}.${this.escapeID(columnName)}`;
76
+ return `${this.getEscapedTableName(Model)}.${this.escapeID(columnName)}`;
77
+ }
78
+
79
+ getEscapedTableName(_modelOrField, options) {
80
+ let Model = (_modelOrField.Model) ? _modelOrField.Model : _modelOrField;
81
+ let tableName = Model.getTableName(this.connection);
82
+
83
+ if (options && options.tableNamePrefix)
84
+ tableName = `${options.tableNamePrefix}${tableName}`;
85
+
86
+ return this.escapeID(tableName);
80
87
  }
81
88
 
82
89
  // eslint-disable-next-line no-unused-vars
@@ -361,7 +368,8 @@ class QueryGeneratorBase {
361
368
  let projectedFields = _projectedFields;
362
369
  let result;
363
370
 
364
- if (options && options.isSubQuery) {
371
+ let subQueryOperator = (options && options.subQueryOperator);
372
+ if (options && options.isSubQuery && !(subQueryOperator === 'EXISTS' || subQueryOperator === 'NOT EXISTS')) {
365
373
  // If we are sub-selecting then only one
366
374
  // field in the projection is allowed
367
375
 
@@ -773,19 +781,6 @@ class QueryGeneratorBase {
773
781
  return orderLimitOffset;
774
782
  }
775
783
 
776
- queryHasConditions(query) {
777
- for (let i = 0, il = query.length; i < il; i++) {
778
- let queryPart = query[i];
779
- if (!Object.prototype.hasOwnProperty.call(queryPart, 'condition'))
780
- continue;
781
-
782
- if (queryPart.condition === true)
783
- return true;
784
- }
785
-
786
- return false;
787
- }
788
-
789
784
  getQuerySliceFromQueryPart(queryPart) {
790
785
  let queryRoot = queryPart.queryRoot;
791
786
  let index = queryRoot.indexOf(queryPart);
@@ -838,6 +833,17 @@ class QueryGeneratorBase {
838
833
  return `DISTINCT ${this.getEscapedProjectionName(field.Model, field, this.stackAssign(options, literal.options))}`;
839
834
  }
840
835
 
836
+ _fieldLiteralToString(literal, options) {
837
+ if (!literal || !LiteralBase.isLiteral(literal))
838
+ return;
839
+
840
+ let field = literal.getField(this.connection);
841
+ if (LiteralBase.isLiteral(field))
842
+ return field.toString(this.connection, options);
843
+
844
+ return this.getEscapedColumnName(field.Model, field, this.stackAssign(options, literal.options));
845
+ }
846
+
841
847
  _maxLiteralToString(literal, options) {
842
848
  if (!literal || !LiteralBase.isLiteral(literal))
843
849
  return;
package/lib/field.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import ConnectionBase from './connection/connection-base';
2
+ import { GenericObject } from './interfaces/common';
3
+ import { Model, ModelClass } from './model';
4
+ import Type from './types/type';
5
+ import { DefaultValueProvider } from './types/helpers/default-helpers';
6
+
7
+ export declare interface GetSetContext {
8
+ field: Field;
9
+ fieldName: string;
10
+ get: () => any;
11
+ set: (value: any) => void;
12
+ self: Model;
13
+ value: any;
14
+ }
15
+
16
+ export declare interface ValidateContext {
17
+ connection: ConnectionBase;
18
+ Model: ModelClass;
19
+ options: GenericObject;
20
+ self: Model;
21
+ }
22
+
23
+ export declare interface FieldDefinition {
24
+ type: Type;
25
+ primaryKey: boolean;
26
+ fieldName: string;
27
+ columnName: string;
28
+ allowNull: boolean;
29
+ index: boolean | Array<boolean | string | Array<string>>;
30
+ unique: boolean;
31
+ defaultValue: any | DefaultValueProvider;
32
+ get: ((context: GetSetContext) => any) | undefined;
33
+ set: ((context: GetSetContext) => void) | undefined;
34
+ validate: (value: any, context: ValidateContext) => Promise<any> | any;
35
+ }
36
+
37
+ declare class Field {
38
+ declare public static _isMythixField: boolean;
39
+
40
+ public static isFieldClass(value: any): boolean;
41
+ public static isField(value: any): boolean;
42
+
43
+ public constructor(fieldDefinition?: Field | FieldDefinition);
44
+ public clone(): Field;
45
+ public setModel(Model: ModelClass): void;
46
+
47
+ declare public Model: ModelClass;
48
+ declare public type: Type;
49
+ declare public primaryKey: boolean;
50
+ declare public fieldName: string;
51
+ declare public columnName: string;
52
+ declare public allowNull: boolean;
53
+ declare public index: boolean | Array<boolean | string | Array<string>>;
54
+ declare public unique: boolean;
55
+ declare public defaultValue: any | DefaultValueProvider;
56
+ declare public get: ((context: GetSetContext) => any) | undefined;
57
+ declare public set: ((context: GetSetContext) => void) | undefined;
58
+ declare public validate: (value: any, context: ValidateContext) => Promise<any> | any;
59
+ }
60
+
61
+ export default Field;
package/lib/field.js CHANGED
@@ -175,6 +175,7 @@ class Field {
175
175
  /// `true` if the provided value is a <see>Field</see>
176
176
  /// class, or inherits from <see>Field</see>. `false`
177
177
  /// otherwise.
178
+ ///
178
179
  /// Arguments:
179
180
  /// value: any
180
181
  /// The value to check.
@@ -208,6 +209,7 @@ class Field {
208
209
  /// `true` if the provided value is a <see>Field</see>
209
210
  /// instance, or inherits from <see>Field</see>. `false`
210
211
  /// otherwise.
212
+ ///
211
213
  /// Arguments:
212
214
  /// value: any
213
215
  /// The value to check.
@@ -232,10 +234,16 @@ class Field {
232
234
  /// the field attributes.
233
235
  ///
234
236
  /// Return: <see>Field</see>
237
+ ///
235
238
  /// Arguments:
236
239
  /// fieldDescription: object | <see>Field</see>
237
240
  /// The attributes to provide to this field.
238
241
  constructor(fieldDefinition) {
242
+ this.primaryKey = false;
243
+ this.allowNull = true;
244
+ this.index = false;
245
+ this.unique = false;
246
+
239
247
  Object.assign(this, fieldDefinition || {});
240
248
  }
241
249
 
@@ -252,6 +260,7 @@ class Field {
252
260
  /// for this field.
253
261
  ///
254
262
  /// Return: undefined
263
+ ///
255
264
  /// Arguments:
256
265
  /// Model: class <see>Model</see>
257
266
  /// The parent model class of this field.
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './field';
2
+ export { default as Field } from './field';
3
+ export * from './model';
4
+ export * as Types from './types';
5
+ export * from './query-engine';
6
+ export * as Utils from './utils';
7
+ export * from './connection';
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const Errors = require('./errors');
4
4
  const Field = require('./field');
5
- const Model = require('./model');
5
+ const _ModelScope = require('./model');
6
6
  const ProxyClass = require('./proxy-class');
7
7
  const QueryEngineScope = require('./query-engine');
8
8
  const ConnectionScope = require('./connection');
@@ -22,10 +22,16 @@ const {
22
22
  QueryGeneratorBase,
23
23
  } = ConnectionScope;
24
24
 
25
+ const {
26
+ Model,
27
+ CacheKey,
28
+ } = _ModelScope;
29
+
25
30
  module.exports = {
26
31
  Errors,
27
32
  Field,
28
33
  Model,
34
+ CacheKey,
29
35
  ProxyClass,
30
36
  Types,
31
37
  Utils,
@@ -0,0 +1,3 @@
1
+ export interface GenericObject {
2
+ [key: string]: any;
3
+ };