@nocobase/plugin-collection-tree 2.0.0-alpha.53 → 2.0.0-alpha.55

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.
@@ -8,11 +8,11 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.0.0-alpha.53",
12
- "@nocobase/database": "2.0.0-alpha.53",
13
- "@nocobase/utils": "2.0.0-alpha.53",
11
+ "@nocobase/client": "2.0.0-alpha.55",
12
+ "@nocobase/database": "2.0.0-alpha.55",
13
+ "@nocobase/utils": "2.0.0-alpha.55",
14
14
  "lodash": "4.17.21",
15
- "@nocobase/data-source-manager": "2.0.0-alpha.53",
16
- "@nocobase/server": "2.0.0-alpha.53",
15
+ "@nocobase/data-source-manager": "2.0.0-alpha.55",
16
+ "@nocobase/server": "2.0.0-alpha.55",
17
17
  "sequelize": "6.35.2"
18
18
  };
@@ -54,7 +54,7 @@ class PluginCollectionTreeServer extends import_server.Plugin {
54
54
  this.app.dataSourceManager.afterAddDataSource((dataSource) => {
55
55
  const collectionManager = dataSource.collectionManager;
56
56
  if (collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
57
- collectionManager.db.on("afterDefineCollection", (collection) => {
57
+ collectionManager.db.on("afterDefineCollection", (collection, eventOptions) => {
58
58
  if (!condition(collection.options)) {
59
59
  return;
60
60
  }
@@ -64,6 +64,9 @@ class PluginCollectionTreeServer extends import_server.Plugin {
64
64
  if (collection.options.schema) {
65
65
  options["schema"] = collection.options.schema;
66
66
  }
67
+ if (eventOptions.fieldModels) {
68
+ options["fieldModels"] = eventOptions.fieldModels;
69
+ }
67
70
  this.defineTreePathCollection(name, options);
68
71
  collectionManager.db.on(`${collection.name}.afterSync`, async ({ transaction }) => {
69
72
  await this.db.getCollection(name).sync({ transaction });
@@ -146,14 +149,21 @@ class PluginCollectionTreeServer extends import_server.Plugin {
146
149
  });
147
150
  }
148
151
  async defineTreePathCollection(name, options) {
152
+ let nodePkType = "bigInt";
153
+ if (options.fieldModels) {
154
+ const pk = options.fieldModels.find((x) => x.options.primaryKey === true);
155
+ if (pk) {
156
+ nodePkType = pk.type;
157
+ }
158
+ }
149
159
  this.db.collection({
150
160
  name,
151
161
  autoGenId: false,
152
162
  timestamps: false,
153
163
  fields: [
154
- { type: "bigInt", name: "nodePk" },
164
+ { type: nodePkType, name: "nodePk" },
155
165
  { type: "string", name: "path", length: 1024 },
156
- { type: "bigInt", name: "rootPk" }
166
+ { type: nodePkType, name: "rootPk" }
157
167
  ],
158
168
  indexes: [
159
169
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-collection-tree",
3
- "version": "2.0.0-alpha.53",
3
+ "version": "2.0.0-alpha.55",
4
4
  "displayName": "Collection: Tree",
5
5
  "displayName.ru-RU": "Древовидная Коллекция",
6
6
  "displayName.zh-CN": "数据表:树",
@@ -16,5 +16,5 @@
16
16
  "@nocobase/server": "2.x",
17
17
  "@nocobase/test": "2.x"
18
18
  },
19
- "gitHead": "ff30cf8261f5a97b3f24c3752af5bbc564167b37"
19
+ "gitHead": "7e65ad6b6e4e76a51f82c69b04b563fbcc7e1c25"
20
20
  }