@nocobase/database 1.8.0-alpha.3 → 1.8.0-alpha.4

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.
@@ -10,7 +10,7 @@ import { Model } from '../model';
10
10
  import { BaseColumnFieldOptions, Field } from './field';
11
11
  export declare class ContextField extends Field {
12
12
  get dataType(): any;
13
- listener: (model: Model, options: any) => Promise<void>;
13
+ listener: (instances: Model[], options: any) => Promise<void>;
14
14
  bind(): void;
15
15
  unbind(): void;
16
16
  }
@@ -48,16 +48,20 @@ const _ContextField = class _ContextField extends import_field.Field {
48
48
  const type = this.options.dataType || "string";
49
49
  return import_sequelize.DataTypes[type.toUpperCase()] || import_sequelize.DataTypes.STRING;
50
50
  }
51
- listener = /* @__PURE__ */ __name(async (model, options) => {
51
+ listener = /* @__PURE__ */ __name(async (instances, options) => {
52
+ instances = Array.isArray(instances) ? instances : [instances];
52
53
  const { name, dataIndex } = this.options;
53
54
  const { context } = options;
54
- model.set(name, import_lodash.default.get(context, dataIndex));
55
- model.changed(name, true);
55
+ for (const instance of instances) {
56
+ instance.set(name, import_lodash.default.get(context, dataIndex));
57
+ instance.changed(name, true);
58
+ }
56
59
  }, "listener");
57
60
  bind() {
58
61
  super.bind();
59
62
  const { createOnly } = this.options;
60
63
  this.on("beforeCreate", this.listener);
64
+ this.on("beforeBulkCreate", this.listener);
61
65
  if (!createOnly) {
62
66
  this.on("beforeUpdate", this.listener);
63
67
  }
@@ -66,6 +70,7 @@ const _ContextField = class _ContextField extends import_field.Field {
66
70
  super.unbind();
67
71
  const { createOnly } = this.options;
68
72
  this.off("beforeCreate", this.listener);
73
+ this.off("beforeBulkCreate", this.listener);
69
74
  if (!createOnly) {
70
75
  this.off("beforeUpdate", this.listener);
71
76
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.8.0-alpha.3",
3
+ "version": "1.8.0-alpha.4",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "AGPL-3.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "1.8.0-alpha.3",
10
- "@nocobase/utils": "1.8.0-alpha.3",
9
+ "@nocobase/logger": "1.8.0-alpha.4",
10
+ "@nocobase/utils": "1.8.0-alpha.4",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -38,5 +38,5 @@
38
38
  "url": "git+https://github.com/nocobase/nocobase.git",
39
39
  "directory": "packages/database"
40
40
  },
41
- "gitHead": "01ed5b3277832af282c7a8ceccae9d74d1db262c"
41
+ "gitHead": "c5079e279d33efdbf5212dd7186574381f29d632"
42
42
  }