@nocobase/database 1.7.15 → 1.7.16

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.
@@ -72,27 +72,32 @@ const _PasswordField = class _PasswordField extends import_field.Field {
72
72
  }
73
73
  init() {
74
74
  const { name } = this.options;
75
- this.listener = async (model) => {
76
- if (!model.changed(name)) {
77
- return;
78
- }
79
- const value = model.get(name);
80
- if (value) {
81
- const hash = await this.hash(value);
82
- model.set(name, hash);
83
- } else {
84
- model.set(name, model.previous(name));
75
+ this.listener = async (instances) => {
76
+ instances = Array.isArray(instances) ? instances : [instances];
77
+ for (const instance of instances) {
78
+ if (!instance.changed(name)) {
79
+ continue;
80
+ }
81
+ const value = instance.get(name);
82
+ if (value) {
83
+ const hash = await this.hash(value);
84
+ instance.set(name, hash);
85
+ } else {
86
+ instance.set(name, instance.previous(name));
87
+ }
85
88
  }
86
89
  };
87
90
  }
88
91
  bind() {
89
92
  super.bind();
90
93
  this.on("beforeCreate", this.listener);
94
+ this.on("beforeBulkCreate", this.listener);
91
95
  this.on("beforeUpdate", this.listener);
92
96
  }
93
97
  unbind() {
94
98
  super.unbind();
95
99
  this.off("beforeCreate", this.listener);
100
+ this.off("beforeBulkCreate", this.listener);
96
101
  this.off("beforeUpdate", this.listener);
97
102
  }
98
103
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.7.15",
3
+ "version": "1.7.16",
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.7.15",
10
- "@nocobase/utils": "1.7.15",
9
+ "@nocobase/logger": "1.7.16",
10
+ "@nocobase/utils": "1.7.16",
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": "9a393c66995fbdaad15e852e3321c7f667fe9644"
41
+ "gitHead": "5801f904778c4dee6d602e1f4728cc4fa95967a9"
42
42
  }