@nocobase/plugin-collection-tree 2.0.0-alpha.59 → 2.0.0-alpha.60

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.59",
12
- "@nocobase/database": "2.0.0-alpha.59",
13
- "@nocobase/utils": "2.0.0-alpha.59",
11
+ "@nocobase/client": "2.0.0-alpha.60",
12
+ "@nocobase/database": "2.0.0-alpha.60",
13
+ "@nocobase/utils": "2.0.0-alpha.60",
14
14
  "lodash": "4.17.21",
15
- "@nocobase/data-source-manager": "2.0.0-alpha.59",
16
- "@nocobase/server": "2.0.0-alpha.59",
15
+ "@nocobase/data-source-manager": "2.0.0-alpha.60",
16
+ "@nocobase/server": "2.0.0-alpha.60",
17
17
  "sequelize": "6.35.2"
18
18
  };
@@ -86,6 +86,24 @@ class PluginCollectionTreeServer extends import_server.Plugin {
86
86
  transaction
87
87
  });
88
88
  });
89
+ this.db.on(`${collection.name}.afterBulkCreate`, async (instances, options2) => {
90
+ const { transaction } = options2;
91
+ const tk = collection.filterTargetKey;
92
+ const records = [];
93
+ for (const model of instances) {
94
+ let path = `/${model.get(tk)}`;
95
+ path = await this.getTreePath(model, path, collection, name, transaction);
96
+ const rootPk = path.split("/")[1] || null;
97
+ records.push({
98
+ nodePk: model.get(tk),
99
+ path,
100
+ rootPk
101
+ });
102
+ }
103
+ await this.app.db.getModel(name).bulkCreate(records, {
104
+ transaction
105
+ });
106
+ });
89
107
  this.db.on(`${collection.name}.afterUpdate`, async (model, options2) => {
90
108
  var _a;
91
109
  const tk = collection.filterTargetKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-collection-tree",
3
- "version": "2.0.0-alpha.59",
3
+ "version": "2.0.0-alpha.60",
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": "ca9fca2a826b17735c6287bebf877b2da9a00e24"
19
+ "gitHead": "9113d61ce85b60b7ba3d0e5ca64182d92a15ece4"
20
20
  }