@nocobase/database 0.7.0-alpha.21 → 0.7.0-alpha.24
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/esm/fields/index.d.ts +3 -1
- package/esm/fields/index.js +1 -0
- package/esm/fields/index.js.map +1 -1
- package/esm/fields/uuid-field.d.ts +9 -0
- package/esm/fields/uuid-field.js +11 -0
- package/esm/fields/uuid-field.js.map +1 -0
- package/lib/fields/index.d.ts +3 -1
- package/lib/fields/index.js +1 -0
- package/lib/fields/index.js.map +1 -1
- package/lib/fields/uuid-field.d.ts +9 -0
- package/lib/fields/uuid-field.js +15 -0
- package/lib/fields/uuid-field.js.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/fields/uuid-field.test.ts +30 -0
- package/src/database.ts +33 -1
- package/src/fields/index.ts +3 -0
- package/src/fields/uuid-field.ts +21 -0
- package/src/model-hook.ts +1 -1
package/esm/fields/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { StringFieldOptions } from './string-field';
|
|
|
16
16
|
import { TextFieldOptions } from './text-field';
|
|
17
17
|
import { TimeFieldOptions } from './time-field';
|
|
18
18
|
import { UidFieldOptions } from './uid-field';
|
|
19
|
+
import { UUIDFieldOptions } from './uuid-field';
|
|
19
20
|
import { VirtualFieldOptions } from './virtual-field';
|
|
20
21
|
export * from './array-field';
|
|
21
22
|
export * from './belongs-to-field';
|
|
@@ -36,5 +37,6 @@ export * from './string-field';
|
|
|
36
37
|
export * from './text-field';
|
|
37
38
|
export * from './time-field';
|
|
38
39
|
export * from './uid-field';
|
|
40
|
+
export * from './uuid-field';
|
|
39
41
|
export * from './virtual-field';
|
|
40
|
-
export declare type FieldOptions = BaseFieldOptions | StringFieldOptions | IntegerFieldOptions | FloatFieldOptions | DecimalFieldOptions | DoubleFieldOptions | RealFieldOptions | JsonFieldOptions | JsonbFieldOptions | BooleanFieldOptions | RadioFieldOptions | SortFieldOptions | TextFieldOptions | VirtualFieldOptions | ArrayFieldOptions | TimeFieldOptions | DateFieldOptions | UidFieldOptions | PasswordFieldOptions | ContextFieldOptions | BelongsToFieldOptions | HasOneFieldOptions | HasManyFieldOptions | BelongsToManyFieldOptions;
|
|
42
|
+
export declare type FieldOptions = BaseFieldOptions | StringFieldOptions | IntegerFieldOptions | FloatFieldOptions | DecimalFieldOptions | DoubleFieldOptions | RealFieldOptions | JsonFieldOptions | JsonbFieldOptions | BooleanFieldOptions | RadioFieldOptions | SortFieldOptions | TextFieldOptions | VirtualFieldOptions | ArrayFieldOptions | TimeFieldOptions | DateFieldOptions | UidFieldOptions | UUIDFieldOptions | PasswordFieldOptions | ContextFieldOptions | BelongsToFieldOptions | HasOneFieldOptions | HasManyFieldOptions | BelongsToManyFieldOptions;
|
package/esm/fields/index.js
CHANGED
package/esm/fields/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AA2BA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC","sourcesContent":["import { ArrayFieldOptions } from './array-field';\nimport { BelongsToFieldOptions } from './belongs-to-field';\nimport { BelongsToManyFieldOptions } from './belongs-to-many-field';\nimport { BooleanFieldOptions } from './boolean-field';\nimport { ContextFieldOptions } from './context-field';\nimport { DateFieldOptions } from './date-field';\nimport { BaseFieldOptions } from './field';\nimport { HasManyFieldOptions } from './has-many-field';\nimport { HasOneFieldOptions } from './has-one-field';\nimport { JsonbFieldOptions, JsonFieldOptions } from './json-field';\nimport {\n DecimalFieldOptions,\n DoubleFieldOptions,\n FloatFieldOptions,\n IntegerFieldOptions,\n RealFieldOptions\n} from './number-field';\nimport { PasswordFieldOptions } from './password-field';\nimport { RadioFieldOptions } from './radio-field';\nimport { SortFieldOptions } from './sort-field';\nimport { StringFieldOptions } from './string-field';\nimport { TextFieldOptions } from './text-field';\nimport { TimeFieldOptions } from './time-field';\nimport { UidFieldOptions } from './uid-field';\nimport { UUIDFieldOptions } from './uuid-field';\nimport { VirtualFieldOptions } from './virtual-field';\n\nexport * from './array-field';\nexport * from './belongs-to-field';\nexport * from './belongs-to-many-field';\nexport * from './boolean-field';\nexport * from './context-field';\nexport * from './date-field';\nexport * from './field';\nexport * from './has-many-field';\nexport * from './has-one-field';\nexport * from './json-field';\nexport * from './number-field';\nexport * from './password-field';\nexport * from './radio-field';\nexport * from './relation-field';\nexport * from './sort-field';\nexport * from './string-field';\nexport * from './text-field';\nexport * from './time-field';\nexport * from './uid-field';\nexport * from './uuid-field';\nexport * from './virtual-field';\n\nexport type FieldOptions =\n | BaseFieldOptions\n | StringFieldOptions\n | IntegerFieldOptions\n | FloatFieldOptions\n | DecimalFieldOptions\n | DoubleFieldOptions\n | RealFieldOptions\n | JsonFieldOptions\n | JsonbFieldOptions\n | BooleanFieldOptions\n | RadioFieldOptions\n | SortFieldOptions\n | TextFieldOptions\n | VirtualFieldOptions\n | ArrayFieldOptions\n | TimeFieldOptions\n | DateFieldOptions\n | UidFieldOptions\n | UUIDFieldOptions\n | PasswordFieldOptions\n | ContextFieldOptions\n | BelongsToFieldOptions\n | HasOneFieldOptions\n | HasManyFieldOptions\n | BelongsToManyFieldOptions;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field, FieldContext } from './field';
|
|
3
|
+
export declare class UuidField extends Field {
|
|
4
|
+
constructor(options?: any, context?: FieldContext);
|
|
5
|
+
get dataType(): DataTypes.AbstractDataTypeConstructor;
|
|
6
|
+
}
|
|
7
|
+
export interface UUIDFieldOptions extends BaseColumnFieldOptions {
|
|
8
|
+
type: 'uuid';
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { Field } from './field';
|
|
3
|
+
export class UuidField extends Field {
|
|
4
|
+
constructor(options, context) {
|
|
5
|
+
super(Object.assign({ defaultValue: DataTypes.UUIDV4 }, options), context);
|
|
6
|
+
}
|
|
7
|
+
get dataType() {
|
|
8
|
+
return DataTypes.UUID;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=uuid-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-field.js","sourceRoot":"","sources":["../../src/fields/uuid-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAA0B,KAAK,EAAgB,MAAM,SAAS,CAAC;AAEtE,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAa,EAAE,OAAsB;QAC/C,KAAK,iBAED,YAAY,EAAE,SAAS,CAAC,MAAM,IAC3B,OAAO,GAEZ,OAAO,CACR,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ;QACV,OAAO,SAAS,CAAC,IAAI,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { DataTypes } from 'sequelize';\nimport { BaseColumnFieldOptions, Field, FieldContext } from './field';\n\nexport class UuidField extends Field {\n constructor(options?: any, context?: FieldContext) {\n super(\n {\n defaultValue: DataTypes.UUIDV4,\n ...options,\n },\n context,\n );\n }\n get dataType() {\n return DataTypes.UUID;\n }\n}\n\nexport interface UUIDFieldOptions extends BaseColumnFieldOptions {\n type: 'uuid';\n}\n"]}
|
package/lib/fields/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { StringFieldOptions } from './string-field';
|
|
|
16
16
|
import { TextFieldOptions } from './text-field';
|
|
17
17
|
import { TimeFieldOptions } from './time-field';
|
|
18
18
|
import { UidFieldOptions } from './uid-field';
|
|
19
|
+
import { UUIDFieldOptions } from './uuid-field';
|
|
19
20
|
import { VirtualFieldOptions } from './virtual-field';
|
|
20
21
|
export * from './array-field';
|
|
21
22
|
export * from './belongs-to-field';
|
|
@@ -36,5 +37,6 @@ export * from './string-field';
|
|
|
36
37
|
export * from './text-field';
|
|
37
38
|
export * from './time-field';
|
|
38
39
|
export * from './uid-field';
|
|
40
|
+
export * from './uuid-field';
|
|
39
41
|
export * from './virtual-field';
|
|
40
|
-
export declare type FieldOptions = BaseFieldOptions | StringFieldOptions | IntegerFieldOptions | FloatFieldOptions | DecimalFieldOptions | DoubleFieldOptions | RealFieldOptions | JsonFieldOptions | JsonbFieldOptions | BooleanFieldOptions | RadioFieldOptions | SortFieldOptions | TextFieldOptions | VirtualFieldOptions | ArrayFieldOptions | TimeFieldOptions | DateFieldOptions | UidFieldOptions | PasswordFieldOptions | ContextFieldOptions | BelongsToFieldOptions | HasOneFieldOptions | HasManyFieldOptions | BelongsToManyFieldOptions;
|
|
42
|
+
export declare type FieldOptions = BaseFieldOptions | StringFieldOptions | IntegerFieldOptions | FloatFieldOptions | DecimalFieldOptions | DoubleFieldOptions | RealFieldOptions | JsonFieldOptions | JsonbFieldOptions | BooleanFieldOptions | RadioFieldOptions | SortFieldOptions | TextFieldOptions | VirtualFieldOptions | ArrayFieldOptions | TimeFieldOptions | DateFieldOptions | UidFieldOptions | UUIDFieldOptions | PasswordFieldOptions | ContextFieldOptions | BelongsToFieldOptions | HasOneFieldOptions | HasManyFieldOptions | BelongsToManyFieldOptions;
|
package/lib/fields/index.js
CHANGED
|
@@ -29,5 +29,6 @@ __exportStar(require("./string-field"), exports);
|
|
|
29
29
|
__exportStar(require("./text-field"), exports);
|
|
30
30
|
__exportStar(require("./time-field"), exports);
|
|
31
31
|
__exportStar(require("./uid-field"), exports);
|
|
32
|
+
__exportStar(require("./uuid-field"), exports);
|
|
32
33
|
__exportStar(require("./virtual-field"), exports);
|
|
33
34
|
//# sourceMappingURL=index.js.map
|
package/lib/fields/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AA2BA,gDAA8B;AAC9B,qDAAmC;AACnC,0DAAwC;AACxC,kDAAgC;AAChC,kDAAgC;AAChC,+CAA6B;AAC7B,0CAAwB;AACxB,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,iDAA+B;AAC/B,mDAAiC;AACjC,gDAA8B;AAC9B,mDAAiC;AACjC,+CAA6B;AAC7B,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAC5B,+CAA6B;AAC7B,kDAAgC","sourcesContent":["import { ArrayFieldOptions } from './array-field';\nimport { BelongsToFieldOptions } from './belongs-to-field';\nimport { BelongsToManyFieldOptions } from './belongs-to-many-field';\nimport { BooleanFieldOptions } from './boolean-field';\nimport { ContextFieldOptions } from './context-field';\nimport { DateFieldOptions } from './date-field';\nimport { BaseFieldOptions } from './field';\nimport { HasManyFieldOptions } from './has-many-field';\nimport { HasOneFieldOptions } from './has-one-field';\nimport { JsonbFieldOptions, JsonFieldOptions } from './json-field';\nimport {\n DecimalFieldOptions,\n DoubleFieldOptions,\n FloatFieldOptions,\n IntegerFieldOptions,\n RealFieldOptions\n} from './number-field';\nimport { PasswordFieldOptions } from './password-field';\nimport { RadioFieldOptions } from './radio-field';\nimport { SortFieldOptions } from './sort-field';\nimport { StringFieldOptions } from './string-field';\nimport { TextFieldOptions } from './text-field';\nimport { TimeFieldOptions } from './time-field';\nimport { UidFieldOptions } from './uid-field';\nimport { UUIDFieldOptions } from './uuid-field';\nimport { VirtualFieldOptions } from './virtual-field';\n\nexport * from './array-field';\nexport * from './belongs-to-field';\nexport * from './belongs-to-many-field';\nexport * from './boolean-field';\nexport * from './context-field';\nexport * from './date-field';\nexport * from './field';\nexport * from './has-many-field';\nexport * from './has-one-field';\nexport * from './json-field';\nexport * from './number-field';\nexport * from './password-field';\nexport * from './radio-field';\nexport * from './relation-field';\nexport * from './sort-field';\nexport * from './string-field';\nexport * from './text-field';\nexport * from './time-field';\nexport * from './uid-field';\nexport * from './uuid-field';\nexport * from './virtual-field';\n\nexport type FieldOptions =\n | BaseFieldOptions\n | StringFieldOptions\n | IntegerFieldOptions\n | FloatFieldOptions\n | DecimalFieldOptions\n | DoubleFieldOptions\n | RealFieldOptions\n | JsonFieldOptions\n | JsonbFieldOptions\n | BooleanFieldOptions\n | RadioFieldOptions\n | SortFieldOptions\n | TextFieldOptions\n | VirtualFieldOptions\n | ArrayFieldOptions\n | TimeFieldOptions\n | DateFieldOptions\n | UidFieldOptions\n | UUIDFieldOptions\n | PasswordFieldOptions\n | ContextFieldOptions\n | BelongsToFieldOptions\n | HasOneFieldOptions\n | HasManyFieldOptions\n | BelongsToManyFieldOptions;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field, FieldContext } from './field';
|
|
3
|
+
export declare class UuidField extends Field {
|
|
4
|
+
constructor(options?: any, context?: FieldContext);
|
|
5
|
+
get dataType(): DataTypes.AbstractDataTypeConstructor;
|
|
6
|
+
}
|
|
7
|
+
export interface UUIDFieldOptions extends BaseColumnFieldOptions {
|
|
8
|
+
type: 'uuid';
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UuidField = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
const field_1 = require("./field");
|
|
6
|
+
class UuidField extends field_1.Field {
|
|
7
|
+
constructor(options, context) {
|
|
8
|
+
super(Object.assign({ defaultValue: sequelize_1.DataTypes.UUIDV4 }, options), context);
|
|
9
|
+
}
|
|
10
|
+
get dataType() {
|
|
11
|
+
return sequelize_1.DataTypes.UUID;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.UuidField = UuidField;
|
|
15
|
+
//# sourceMappingURL=uuid-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-field.js","sourceRoot":"","sources":["../../src/fields/uuid-field.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,mCAAsE;AAEtE,MAAa,SAAU,SAAQ,aAAK;IAClC,YAAY,OAAa,EAAE,OAAsB;QAC/C,KAAK,iBAED,YAAY,EAAE,qBAAS,CAAC,MAAM,IAC3B,OAAO,GAEZ,OAAO,CACR,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ;QACV,OAAO,qBAAS,CAAC,IAAI,CAAC;IACxB,CAAC;CACF;AAbD,8BAaC","sourcesContent":["import { DataTypes } from 'sequelize';\nimport { BaseColumnFieldOptions, Field, FieldContext } from './field';\n\nexport class UuidField extends Field {\n constructor(options?: any, context?: FieldContext) {\n super(\n {\n defaultValue: DataTypes.UUIDV4,\n ...options,\n },\n context,\n );\n }\n get dataType() {\n return DataTypes.UUID;\n }\n}\n\nexport interface UUIDFieldOptions extends BaseColumnFieldOptions {\n type: 'uuid';\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@nocobase/utils": "0.7.0-alpha.
|
|
20
|
+
"@nocobase/utils": "0.7.0-alpha.24",
|
|
21
21
|
"async-mutex": "^0.3.2",
|
|
22
22
|
"deepmerge": "^4.2.2",
|
|
23
23
|
"flat": "^5.0.2",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
30
30
|
"directory": "packages/database"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "1fb2dd884c4f2d2167f5dde40a15012a752e53ab"
|
|
33
33
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mockDatabase } from '../';
|
|
2
|
+
import { Database } from '../../database';
|
|
3
|
+
|
|
4
|
+
describe('string field', () => {
|
|
5
|
+
let db: Database;
|
|
6
|
+
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
db = mockDatabase();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
afterEach(async () => {
|
|
12
|
+
await db.close();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('define', async () => {
|
|
16
|
+
const Test = db.collection({
|
|
17
|
+
name: 'tests',
|
|
18
|
+
autoGenId: false,
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
type: 'uuid',
|
|
22
|
+
name: 'id',
|
|
23
|
+
primaryKey: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
await Test.sync();
|
|
28
|
+
await Test.model.create();
|
|
29
|
+
});
|
|
30
|
+
});
|
package/src/database.ts
CHANGED
|
@@ -2,7 +2,16 @@ import { applyMixins, AsyncEmitter } from '@nocobase/utils';
|
|
|
2
2
|
import merge from 'deepmerge';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import lodash from 'lodash';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ModelCtor,
|
|
7
|
+
Op,
|
|
8
|
+
Options,
|
|
9
|
+
QueryInterfaceDropAllTablesOptions,
|
|
10
|
+
QueryOptions,
|
|
11
|
+
Sequelize,
|
|
12
|
+
SyncOptions,
|
|
13
|
+
Utils
|
|
14
|
+
} from 'sequelize';
|
|
6
15
|
import { Collection, CollectionOptions, RepositoryType } from './collection';
|
|
7
16
|
import { ImporterReader, ImportFileExtension } from './collection-importer';
|
|
8
17
|
import * as FieldTypes from './fields';
|
|
@@ -248,6 +257,29 @@ export class Database extends EventEmitter implements AsyncEmitter {
|
|
|
248
257
|
return this.sequelize.getDialect() === 'sqlite' && lodash.get(this.options, 'storage') == ':memory:';
|
|
249
258
|
}
|
|
250
259
|
|
|
260
|
+
async auth(options: QueryOptions & { repeat?: number } = {}) {
|
|
261
|
+
const { repeat = 10, ...others } = options;
|
|
262
|
+
const delay = (ms) => new Promise((yea) => setTimeout(yea, ms));
|
|
263
|
+
let count = 0;
|
|
264
|
+
const authenticate = async () => {
|
|
265
|
+
try {
|
|
266
|
+
await this.sequelize.authenticate(others);
|
|
267
|
+
console.log('Connection has been established successfully.');
|
|
268
|
+
return true;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.log('reconnecting...', count);
|
|
271
|
+
if (count >= repeat) {
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
++count;
|
|
275
|
+
await delay(500);
|
|
276
|
+
return await authenticate();
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
return await authenticate();
|
|
281
|
+
}
|
|
282
|
+
|
|
251
283
|
async reconnect() {
|
|
252
284
|
if (this.isSqliteMemory()) {
|
|
253
285
|
return;
|
package/src/fields/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { StringFieldOptions } from './string-field';
|
|
|
22
22
|
import { TextFieldOptions } from './text-field';
|
|
23
23
|
import { TimeFieldOptions } from './time-field';
|
|
24
24
|
import { UidFieldOptions } from './uid-field';
|
|
25
|
+
import { UUIDFieldOptions } from './uuid-field';
|
|
25
26
|
import { VirtualFieldOptions } from './virtual-field';
|
|
26
27
|
|
|
27
28
|
export * from './array-field';
|
|
@@ -43,6 +44,7 @@ export * from './string-field';
|
|
|
43
44
|
export * from './text-field';
|
|
44
45
|
export * from './time-field';
|
|
45
46
|
export * from './uid-field';
|
|
47
|
+
export * from './uuid-field';
|
|
46
48
|
export * from './virtual-field';
|
|
47
49
|
|
|
48
50
|
export type FieldOptions =
|
|
@@ -64,6 +66,7 @@ export type FieldOptions =
|
|
|
64
66
|
| TimeFieldOptions
|
|
65
67
|
| DateFieldOptions
|
|
66
68
|
| UidFieldOptions
|
|
69
|
+
| UUIDFieldOptions
|
|
67
70
|
| PasswordFieldOptions
|
|
68
71
|
| ContextFieldOptions
|
|
69
72
|
| BelongsToFieldOptions
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field, FieldContext } from './field';
|
|
3
|
+
|
|
4
|
+
export class UuidField extends Field {
|
|
5
|
+
constructor(options?: any, context?: FieldContext) {
|
|
6
|
+
super(
|
|
7
|
+
{
|
|
8
|
+
defaultValue: DataTypes.UUIDV4,
|
|
9
|
+
...options,
|
|
10
|
+
},
|
|
11
|
+
context,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
get dataType() {
|
|
15
|
+
return DataTypes.UUID;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface UUIDFieldOptions extends BaseColumnFieldOptions {
|
|
20
|
+
type: 'uuid';
|
|
21
|
+
}
|