@nocobase/database 0.20.0-alpha.9 → 0.21.0-alpha.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/database.d.ts CHANGED
@@ -10,7 +10,7 @@ import { CollectionFactory } from './collection-factory';
10
10
  import { CollectionGroupManager } from './collection-group-manager';
11
11
  import { ImportFileExtension } from './collection-importer';
12
12
  import DatabaseUtils from './database-utils';
13
- import ReferencesMap from './features/ReferencesMap';
13
+ import ReferencesMap from './features/references-map';
14
14
  import { ArrayFieldRepository } from './field-repository/array-field-repository';
15
15
  import * as FieldTypes from './fields';
16
16
  import { Field, FieldContext, RelationField } from './fields';
package/lib/database.js CHANGED
@@ -52,7 +52,7 @@ var import_collection_factory = require("./collection-factory");
52
52
  var import_collection_group_manager = require("./collection-group-manager");
53
53
  var import_collection_importer = require("./collection-importer");
54
54
  var import_database_utils = __toESM(require("./database-utils"));
55
- var import_ReferencesMap = __toESM(require("./features/ReferencesMap"));
55
+ var import_references_map = __toESM(require("./features/references-map"));
56
56
  var import_referential_integrity_check = require("./features/referential-integrity-check");
57
57
  var FieldTypes = __toESM(require("./fields"));
58
58
  var import_helpers = require("./helpers");
@@ -137,7 +137,7 @@ const _Database = class _Database extends import_events.EventEmitter {
137
137
  context = {};
138
138
  queryInterface;
139
139
  utils = new import_database_utils.default(this);
140
- referenceMap = new import_ReferencesMap.default();
140
+ referenceMap = new import_references_map.default();
141
141
  inheritanceMap = new import_inherited_map.default();
142
142
  importedFrom = /* @__PURE__ */ new Map();
143
143
  modelHook;
@@ -1,10 +1,13 @@
1
+ export type ReferencePriority = 'default' | 'user';
1
2
  export interface Reference {
2
3
  sourceCollectionName: string;
3
4
  sourceField: string;
4
5
  targetField: string;
5
6
  targetCollectionName: string;
6
7
  onDelete: string;
8
+ priority: ReferencePriority;
7
9
  }
10
+ export declare function buildReference(options: Partial<Reference>): Reference;
8
11
  declare class ReferencesMap {
9
12
  protected map: Map<string, Reference[]>;
10
13
  addReference(reference: Reference): void;
@@ -16,30 +16,56 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var ReferencesMap_exports = {};
20
- __export(ReferencesMap_exports, {
21
- default: () => ReferencesMap_default
19
+ var references_map_exports = {};
20
+ __export(references_map_exports, {
21
+ buildReference: () => buildReference,
22
+ default: () => references_map_default
22
23
  });
23
- module.exports = __toCommonJS(ReferencesMap_exports);
24
+ module.exports = __toCommonJS(references_map_exports);
25
+ const DEFAULT_ON_DELETE = "NO ACTION";
26
+ function buildReference(options) {
27
+ const { sourceCollectionName, sourceField, targetField, targetCollectionName, onDelete, priority } = options;
28
+ return {
29
+ sourceCollectionName,
30
+ sourceField,
31
+ targetField,
32
+ targetCollectionName,
33
+ onDelete: (onDelete || DEFAULT_ON_DELETE).toUpperCase(),
34
+ priority: assignPriority(priority, onDelete)
35
+ };
36
+ }
37
+ __name(buildReference, "buildReference");
38
+ function assignPriority(priority, onDelete) {
39
+ if (priority) {
40
+ return priority;
41
+ }
42
+ return onDelete ? "user" : "default";
43
+ }
44
+ __name(assignPriority, "assignPriority");
45
+ const PRIORITY_MAP = {
46
+ default: 1,
47
+ user: 2
48
+ };
24
49
  const _ReferencesMap = class _ReferencesMap {
25
50
  map = /* @__PURE__ */ new Map();
26
51
  addReference(reference) {
27
- if (!reference.onDelete) {
28
- reference.onDelete = "SET NULL";
29
- }
30
- reference.onDelete = reference.onDelete.toUpperCase();
31
52
  const existReference = this.existReference(reference);
32
53
  if (existReference && existReference.onDelete !== reference.onDelete) {
33
- if (reference.onDelete === "SET NULL") {
34
- return;
35
- } else if (existReference.onDelete === "SET NULL") {
54
+ const existPriority = PRIORITY_MAP[existReference.priority];
55
+ const newPriority = PRIORITY_MAP[reference.priority];
56
+ if (newPriority > existPriority) {
36
57
  existReference.onDelete = reference.onDelete;
37
- } else {
38
- throw new Error(
39
- `On Delete Conflict, exist reference ${JSON.stringify(existReference)}, new reference ${JSON.stringify(
40
- reference
41
- )}`
42
- );
58
+ existReference.priority = reference.priority;
59
+ } else if (newPriority === existPriority && newPriority === PRIORITY_MAP["user"]) {
60
+ if (existReference.onDelete === "SET NULL" && reference.onDelete === "CASCADE") {
61
+ existReference.onDelete = reference.onDelete;
62
+ } else {
63
+ throw new Error(
64
+ `On Delete Conflict, exist reference ${JSON.stringify(existReference)}, new reference ${JSON.stringify(
65
+ reference
66
+ )}`
67
+ );
68
+ }
43
69
  }
44
70
  }
45
71
  if (!existReference) {
@@ -57,7 +83,7 @@ const _ReferencesMap = class _ReferencesMap {
57
83
  if (!references) {
58
84
  return null;
59
85
  }
60
- const keys = Object.keys(reference).filter((k) => k !== "onDelete");
86
+ const keys = Object.keys(reference).filter((k) => k !== "onDelete" && k !== "priority");
61
87
  return references.find((ref) => keys.every((key) => ref[key] === reference[key]));
62
88
  }
63
89
  removeReference(reference) {
@@ -74,4 +100,8 @@ const _ReferencesMap = class _ReferencesMap {
74
100
  };
75
101
  __name(_ReferencesMap, "ReferencesMap");
76
102
  let ReferencesMap = _ReferencesMap;
77
- var ReferencesMap_default = ReferencesMap;
103
+ var references_map_default = ReferencesMap;
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ buildReference
107
+ });
@@ -31,6 +31,9 @@ async function referentialIntegrityCheck(options) {
31
31
  }
32
32
  for (const reference of references) {
33
33
  const { sourceCollectionName, sourceField, targetField, onDelete } = reference;
34
+ if (onDelete === "NO ACTION") {
35
+ continue;
36
+ }
34
37
  const sourceCollection = db.collections.get(sourceCollectionName);
35
38
  const sourceRepository = sourceCollection.repository;
36
39
  if (sourceCollection.isView()) {
@@ -1,17 +1,11 @@
1
1
  import { BelongsToOptions as SequelizeBelongsToOptions } from 'sequelize';
2
- import { Reference } from '../features/ReferencesMap';
2
+ import { Reference, ReferencePriority } from '../features/references-map';
3
3
  import { BaseRelationFieldOptions, RelationField } from './relation-field';
4
4
  export declare class BelongsToField extends RelationField {
5
5
  static type: string;
6
6
  get dataType(): string;
7
7
  get target(): any;
8
- static toReference(db: any, association: any, onDelete: any): {
9
- sourceCollectionName: any;
10
- sourceField: any;
11
- targetField: any;
12
- targetCollectionName: any;
13
- onDelete: any;
14
- };
8
+ static toReference(db: any, association: any, onDelete: any, priority?: ReferencePriority): Reference;
15
9
  reference(association: any): Reference;
16
10
  checkAssociationKeys(): void;
17
11
  bind(): boolean;
@@ -38,6 +38,7 @@ __export(belongs_to_field_exports, {
38
38
  module.exports = __toCommonJS(belongs_to_field_exports);
39
39
  var import_lodash = __toESM(require("lodash"));
40
40
  var import_sequelize = require("sequelize");
41
+ var import_references_map = require("../features/references-map");
41
42
  var import_utils = require("../utils");
42
43
  var import_relation_field = require("./relation-field");
43
44
  const _BelongsToField = class _BelongsToField extends import_relation_field.RelationField {
@@ -48,18 +49,24 @@ const _BelongsToField = class _BelongsToField extends import_relation_field.Rela
48
49
  const { target, name } = this.options;
49
50
  return target || import_sequelize.Utils.pluralize(name);
50
51
  }
51
- static toReference(db, association, onDelete) {
52
+ static toReference(db, association, onDelete, priority = "default") {
52
53
  const targetKey = association.targetKey;
53
- return {
54
+ return (0, import_references_map.buildReference)({
54
55
  sourceCollectionName: db.modelCollection.get(association.source).name,
55
56
  sourceField: association.foreignKey,
56
57
  targetField: targetKey,
57
58
  targetCollectionName: db.modelCollection.get(association.target).name,
58
- onDelete
59
- };
59
+ onDelete,
60
+ priority
61
+ });
60
62
  }
61
63
  reference(association) {
62
- return _BelongsToField.toReference(this.database, association, this.options.onDelete);
64
+ return _BelongsToField.toReference(
65
+ this.database,
66
+ association,
67
+ this.options.onDelete,
68
+ this.options.onDelete ? "user" : "default"
69
+ );
63
70
  }
64
71
  checkAssociationKeys() {
65
72
  let { foreignKey, targetKey } = this.options;
@@ -1,5 +1,5 @@
1
1
  import { AssociationScope, BelongsToManyOptions as SequelizeBelongsToManyOptions } from 'sequelize';
2
- import { Reference } from '../features/ReferencesMap';
2
+ import { Reference } from '../features/references-map';
3
3
  import { MultipleRelationFieldOptions, RelationField } from './relation-field';
4
4
  export declare class BelongsToManyField extends RelationField {
5
5
  get dataType(): string;
@@ -41,6 +41,7 @@ const _BelongsToManyField = class _BelongsToManyField extends import_relation_fi
41
41
  references(association) {
42
42
  const db = this.context.database;
43
43
  const onDelete = this.options.onDelete || "CASCADE";
44
+ const priority = this.options.onDelete ? "user" : "default";
44
45
  const targetAssociation = association.toTarget;
45
46
  if (association.targetKey) {
46
47
  targetAssociation.targetKey = association.targetKey;
@@ -50,8 +51,8 @@ const _BelongsToManyField = class _BelongsToManyField extends import_relation_fi
50
51
  sourceAssociation.targetKey = association.sourceKey;
51
52
  }
52
53
  return [
53
- import_belongs_to_field.BelongsToField.toReference(db, targetAssociation, onDelete),
54
- import_belongs_to_field.BelongsToField.toReference(db, sourceAssociation, onDelete)
54
+ import_belongs_to_field.BelongsToField.toReference(db, targetAssociation, onDelete, priority),
55
+ import_belongs_to_field.BelongsToField.toReference(db, sourceAssociation, onDelete, priority)
55
56
  ];
56
57
  }
57
58
  checkAssociationKeys(database) {
@@ -126,9 +127,6 @@ const _BelongsToManyField = class _BelongsToManyField extends import_relation_fi
126
127
  Through = database.collection(throughCollectionOptions);
127
128
  Object.defineProperty(Through.model, "isThrough", { value: true });
128
129
  }
129
- if (!this.options.onDelete) {
130
- this.options.onDelete = "CASCADE";
131
- }
132
130
  const belongsToManyOptions = {
133
131
  constraints: false,
134
132
  ...(0, import_lodash.omit)(this.options, ["name", "type", "target"]),
@@ -1,5 +1,5 @@
1
1
  import { AssociationScope, DataType, ForeignKeyOptions, HasManyOptions, HasManyOptions as SequelizeHasManyOptions } from 'sequelize';
2
- import { Reference } from '../features/ReferencesMap';
2
+ import { Reference } from '../features/references-map';
3
3
  import { MultipleRelationFieldOptions, RelationField } from './relation-field';
4
4
  export interface HasManyFieldOptions extends HasManyOptions {
5
5
  /**
@@ -23,6 +23,7 @@ __export(has_many_field_exports, {
23
23
  module.exports = __toCommonJS(has_many_field_exports);
24
24
  var import_lodash = require("lodash");
25
25
  var import_sequelize = require("sequelize");
26
+ var import_references_map = require("../features/references-map");
26
27
  var import_utils = require("../utils");
27
28
  var import_relation_field = require("./relation-field");
28
29
  const _HasManyField = class _HasManyField extends import_relation_field.RelationField {
@@ -38,13 +39,13 @@ const _HasManyField = class _HasManyField extends import_relation_field.Relation
38
39
  }
39
40
  reference(association) {
40
41
  const sourceKey = association.sourceKey;
41
- return {
42
+ return (0, import_references_map.buildReference)({
42
43
  sourceCollectionName: this.database.modelCollection.get(association.target).name,
43
44
  sourceField: association.foreignKey,
44
45
  targetField: sourceKey,
45
46
  targetCollectionName: this.database.modelCollection.get(association.source).name,
46
47
  onDelete: this.options.onDelete
47
- };
48
+ });
48
49
  }
49
50
  checkAssociationKeys() {
50
51
  let { foreignKey, sourceKey } = this.options;
@@ -1,5 +1,5 @@
1
1
  import { AssociationScope, DataType, ForeignKeyOptions, HasOneOptions, HasOneOptions as SequelizeHasOneOptions } from 'sequelize';
2
- import { Reference } from '../features/ReferencesMap';
2
+ import { Reference } from '../features/references-map';
3
3
  import { BaseRelationFieldOptions, RelationField } from './relation-field';
4
4
  export interface HasOneFieldOptions extends HasOneOptions {
5
5
  /**
@@ -23,6 +23,7 @@ __export(has_one_field_exports, {
23
23
  module.exports = __toCommonJS(has_one_field_exports);
24
24
  var import_lodash = require("lodash");
25
25
  var import_sequelize = require("sequelize");
26
+ var import_references_map = require("../features/references-map");
26
27
  var import_utils = require("../utils");
27
28
  var import_relation_field = require("./relation-field");
28
29
  const _HasOneField = class _HasOneField extends import_relation_field.RelationField {
@@ -45,13 +46,13 @@ const _HasOneField = class _HasOneField extends import_relation_field.RelationFi
45
46
  }
46
47
  reference(association) {
47
48
  const sourceKey = association.sourceKey;
48
- return {
49
+ return (0, import_references_map.buildReference)({
49
50
  sourceCollectionName: this.database.modelCollection.get(association.target).name,
50
51
  sourceField: association.foreignKey,
51
52
  targetField: sourceKey,
52
53
  targetCollectionName: this.database.modelCollection.get(association.source).name,
53
54
  onDelete: this.options.onDelete
54
- };
55
+ });
55
56
  }
56
57
  checkAssociationKeys() {
57
58
  let { foreignKey, sourceKey } = this.options;
@@ -19,6 +19,7 @@ import { TimeFieldOptions } from './time-field';
19
19
  import { UidFieldOptions } from './uid-field';
20
20
  import { UUIDFieldOptions } from './uuid-field';
21
21
  import { VirtualFieldOptions } from './virtual-field';
22
+ import { NanoidFieldOptions } from './nanoid-field';
22
23
  export * from './array-field';
23
24
  export * from './belongs-to-field';
24
25
  export * from './belongs-to-many-field';
@@ -41,4 +42,5 @@ export * from './time-field';
41
42
  export * from './uid-field';
42
43
  export * from './uuid-field';
43
44
  export * from './virtual-field';
44
- export type FieldOptions = BaseFieldOptions | StringFieldOptions | IntegerFieldOptions | FloatFieldOptions | DecimalFieldOptions | DoubleFieldOptions | RealFieldOptions | JsonFieldOptions | JsonbFieldOptions | BooleanFieldOptions | RadioFieldOptions | SortFieldOptions | TextFieldOptions | VirtualFieldOptions | ArrayFieldOptions | SetFieldOptions | TimeFieldOptions | DateFieldOptions | UidFieldOptions | UUIDFieldOptions | PasswordFieldOptions | ContextFieldOptions | BelongsToFieldOptions | HasOneFieldOptions | HasManyFieldOptions | BelongsToManyFieldOptions;
45
+ export * from './nanoid-field';
46
+ export type FieldOptions = BaseFieldOptions | StringFieldOptions | IntegerFieldOptions | FloatFieldOptions | DecimalFieldOptions | DoubleFieldOptions | RealFieldOptions | JsonFieldOptions | JsonbFieldOptions | BooleanFieldOptions | RadioFieldOptions | SortFieldOptions | TextFieldOptions | VirtualFieldOptions | ArrayFieldOptions | SetFieldOptions | TimeFieldOptions | DateFieldOptions | UidFieldOptions | UUIDFieldOptions | NanoidFieldOptions | PasswordFieldOptions | ContextFieldOptions | BelongsToFieldOptions | HasOneFieldOptions | HasManyFieldOptions | BelongsToManyFieldOptions;
@@ -36,6 +36,7 @@ __reExport(fields_exports, require("./time-field"), module.exports);
36
36
  __reExport(fields_exports, require("./uid-field"), module.exports);
37
37
  __reExport(fields_exports, require("./uuid-field"), module.exports);
38
38
  __reExport(fields_exports, require("./virtual-field"), module.exports);
39
+ __reExport(fields_exports, require("./nanoid-field"), module.exports);
39
40
  // Annotate the CommonJS export names for ESM import in node:
40
41
  0 && (module.exports = {
41
42
  ...require("./array-field"),
@@ -59,5 +60,6 @@ __reExport(fields_exports, require("./virtual-field"), module.exports);
59
60
  ...require("./time-field"),
60
61
  ...require("./uid-field"),
61
62
  ...require("./uuid-field"),
62
- ...require("./virtual-field")
63
+ ...require("./virtual-field"),
64
+ ...require("./nanoid-field")
63
65
  });
@@ -0,0 +1,13 @@
1
+ import { DataTypes } from 'sequelize';
2
+ import { BaseColumnFieldOptions, Field } from './field';
3
+ export declare class NanoidField extends Field {
4
+ get dataType(): DataTypes.StringDataTypeConstructor;
5
+ init(): void;
6
+ bind(): void;
7
+ unbind(): void;
8
+ }
9
+ export interface NanoidFieldOptions extends BaseColumnFieldOptions {
10
+ type: 'nanoid';
11
+ size?: number;
12
+ customAlphabet?: string;
13
+ }
@@ -0,0 +1,58 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var nanoid_field_exports = {};
20
+ __export(nanoid_field_exports, {
21
+ NanoidField: () => NanoidField
22
+ });
23
+ module.exports = __toCommonJS(nanoid_field_exports);
24
+ var import_sequelize = require("sequelize");
25
+ var import_field = require("./field");
26
+ var import_nanoid = require("nanoid");
27
+ const DEFAULT_SIZE = 12;
28
+ const _NanoidField = class _NanoidField extends import_field.Field {
29
+ get dataType() {
30
+ return import_sequelize.DataTypes.STRING;
31
+ }
32
+ init() {
33
+ const { name, size, customAlphabet: customAlphabetOptions } = this.options;
34
+ this.listener = async (instance) => {
35
+ const value = instance.get(name);
36
+ if (!value) {
37
+ const nanoIdFunc = customAlphabetOptions ? (0, import_nanoid.customAlphabet)(customAlphabetOptions) : import_nanoid.nanoid;
38
+ instance.set(name, nanoIdFunc(size || DEFAULT_SIZE));
39
+ }
40
+ };
41
+ }
42
+ bind() {
43
+ super.bind();
44
+ this.on("beforeCreate", this.listener);
45
+ this.on("beforeUpdate", this.listener);
46
+ }
47
+ unbind() {
48
+ super.unbind();
49
+ this.off("beforeCreate", this.listener);
50
+ this.off("beforeUpdate", this.listener);
51
+ }
52
+ };
53
+ __name(_NanoidField, "NanoidField");
54
+ let NanoidField = _NanoidField;
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ NanoidField
58
+ });
@@ -27,7 +27,7 @@ const _UuidField = class _UuidField extends import_field.Field {
27
27
  constructor(options, context) {
28
28
  super(
29
29
  {
30
- defaultValue: import_sequelize.DataTypes.UUIDV4,
30
+ defaultValue: new import_sequelize.DataTypes.UUIDV4(),
31
31
  ...options
32
32
  },
33
33
  context
@@ -1,10 +1,10 @@
1
1
  declare const _default: {
2
2
  postgres: {
3
- 'character varying': string;
4
- varchar: string;
3
+ 'character varying': string[];
4
+ varchar: string[];
5
+ char: string[];
5
6
  character: string;
6
7
  text: string;
7
- char: string;
8
8
  oid: string;
9
9
  name: string;
10
10
  smallint: string[];
@@ -34,10 +34,10 @@ declare const _default: {
34
34
  'smallint unsigned': string[];
35
35
  'tinyint unsigned': string[];
36
36
  'mediumint unsigned': string[];
37
- char: string;
37
+ char: string[];
38
+ varchar: string[];
38
39
  date: string;
39
40
  time: string;
40
- varchar: string;
41
41
  text: string;
42
42
  longtext: string;
43
43
  int: string[];
@@ -52,10 +52,11 @@ declare const _default: {
52
52
  datetime: string;
53
53
  timestamp: string;
54
54
  json: string[];
55
+ enum: string;
55
56
  };
56
57
  sqlite: {
57
58
  text: string;
58
- varchar: string;
59
+ varchar: string[];
59
60
  integer: string;
60
61
  real: string;
61
62
  datetime: string;
@@ -72,10 +73,10 @@ declare const _default: {
72
73
  'smallint unsigned': string[];
73
74
  'tinyint unsigned': string[];
74
75
  'mediumint unsigned': string[];
75
- char: string;
76
+ char: string[];
77
+ varchar: string[];
76
78
  date: string;
77
79
  time: string;
78
- varchar: string;
79
80
  text: string;
80
81
  longtext: string;
81
82
  int: string[];
@@ -90,6 +91,7 @@ declare const _default: {
90
91
  datetime: string;
91
92
  timestamp: string;
92
93
  json: string[];
94
+ enum: string;
93
95
  };
94
96
  };
95
97
  export default _default;
@@ -21,11 +21,11 @@ __export(field_type_map_exports, {
21
21
  });
22
22
  module.exports = __toCommonJS(field_type_map_exports);
23
23
  const postgres = {
24
- "character varying": "string",
25
- varchar: "string",
24
+ "character varying": ["string", "uuid", "nanoid"],
25
+ varchar: ["string", "uuid", "nanoid"],
26
+ char: ["string", "uuid", "nanoid"],
26
27
  character: "string",
27
28
  text: "text",
28
- char: "string",
29
29
  oid: "string",
30
30
  name: "string",
31
31
  smallint: ["integer", "sort"],
@@ -46,7 +46,7 @@ const postgres = {
46
46
  path: "json",
47
47
  polygon: "json",
48
48
  circle: "json",
49
- uuid: "string"
49
+ uuid: "uuid"
50
50
  };
51
51
  const mysql = {
52
52
  smallint: ["integer", "boolean", "sort"],
@@ -55,10 +55,10 @@ const mysql = {
55
55
  "smallint unsigned": ["integer", "boolean", "sort"],
56
56
  "tinyint unsigned": ["integer", "boolean", "sort"],
57
57
  "mediumint unsigned": ["integer", "boolean", "sort"],
58
- char: "string",
58
+ char: ["string", "uuid", "nanoid"],
59
+ varchar: ["string", "uuid", "nanoid"],
59
60
  date: "date",
60
61
  time: "time",
61
- varchar: "string",
62
62
  text: "text",
63
63
  longtext: "text",
64
64
  int: ["integer", "sort"],
@@ -72,11 +72,12 @@ const mysql = {
72
72
  decimal: "decimal",
73
73
  datetime: "date",
74
74
  timestamp: "date",
75
- json: ["json", "array"]
75
+ json: ["json", "array"],
76
+ enum: "string"
76
77
  };
77
78
  const sqlite = {
78
79
  text: "text",
79
- varchar: "string",
80
+ varchar: ["string", "uuid", "nanoid"],
80
81
  integer: "integer",
81
82
  real: "real",
82
83
  datetime: "date",
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "0.20.0-alpha.9",
3
+ "version": "0.21.0-alpha.1",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "Apache-2.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "0.20.0-alpha.9",
10
- "@nocobase/utils": "0.20.0-alpha.9",
9
+ "@nocobase/logger": "0.21.0-alpha.1",
10
+ "@nocobase/utils": "0.21.0-alpha.1",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -35,5 +35,5 @@
35
35
  "url": "git+https://github.com/nocobase/nocobase.git",
36
36
  "directory": "packages/database"
37
37
  },
38
- "gitHead": "5473d9039cfdb649a8c8c625edefc9a3ac464be5"
38
+ "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
39
39
  }