@nocobase/database 1.8.0-beta.10 → 1.8.0-beta.12

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/lib/helpers.js CHANGED
@@ -96,6 +96,29 @@ function extractSSLOptionsFromEnv() {
96
96
  });
97
97
  }
98
98
  __name(extractSSLOptionsFromEnv, "extractSSLOptionsFromEnv");
99
+ function getPoolOptions() {
100
+ const options = {};
101
+ if (process.env.DB_POOL_MAX) {
102
+ options.max = Number.parseInt(process.env.DB_POOL_MAX, 10);
103
+ }
104
+ if (process.env.DB_POOL_MIN) {
105
+ options.min = Number.parseInt(process.env.DB_POOL_MIN, 10);
106
+ }
107
+ if (process.env.DB_POOL_IDLE) {
108
+ options.idle = Number.parseInt(process.env.DB_POOL_IDLE, 10);
109
+ }
110
+ if (process.env.DB_POOL_ACQUIRE) {
111
+ options.acquire = Number.parseInt(process.env.DB_POOL_ACQUIRE, 10);
112
+ }
113
+ if (process.env.DB_POOL_EVICT) {
114
+ options.evict = Number.parseInt(process.env.DB_POOL_EVICT, 10);
115
+ }
116
+ if (process.env.DB_POOL_MAX_USES) {
117
+ options.maxUses = Number.parseInt(process.env.DB_POOL_MAX_USES, 10) || Number.POSITIVE_INFINITY;
118
+ }
119
+ return options;
120
+ }
121
+ __name(getPoolOptions, "getPoolOptions");
99
122
  async function parseDatabaseOptionsFromEnv() {
100
123
  const databaseOptions = {
101
124
  logging: process.env.DB_LOGGING == "on" ? customLogger : false,
@@ -109,7 +132,8 @@ async function parseDatabaseOptionsFromEnv() {
109
132
  timezone: process.env.DB_TIMEZONE,
110
133
  tablePrefix: process.env.DB_TABLE_PREFIX,
111
134
  schema: process.env.DB_SCHEMA,
112
- underscored: process.env.DB_UNDERSCORED === "true"
135
+ underscored: process.env.DB_UNDERSCORED === "true",
136
+ pool: getPoolOptions()
113
137
  };
114
138
  const sslOptions = await extractSSLOptionsFromEnv();
115
139
  if (Object.keys(sslOptions).length) {
@@ -61,7 +61,7 @@ const toDate = /* @__PURE__ */ __name((date, options = {}) => {
61
61
  val = (0, import_moment.default)(val).utcOffset("+00:00").format("YYYY-MM-DD HH:mm:ss");
62
62
  }
63
63
  if (field.constructor.name === "DateOnlyField") {
64
- val = (0, import_moment.default)(val).format("YYYY-MM-DD HH:mm:ss");
64
+ val = import_moment.default.utc(val).format("YYYY-MM-DD HH:mm:ss");
65
65
  }
66
66
  const eventObj = {
67
67
  val,
@@ -95,6 +95,9 @@ var date_default = {
95
95
  };
96
96
  }
97
97
  if (Array.isArray(r)) {
98
+ console.log(11111111, {
99
+ [import_sequelize.Op.and]: [{ [import_sequelize.Op.gte]: toDate(r[0], { ctx }) }, { [import_sequelize.Op.lt]: toDate(r[1], { ctx }) }]
100
+ });
98
101
  return {
99
102
  [import_sequelize.Op.and]: [{ [import_sequelize.Op.gte]: toDate(r[0], { ctx }) }, { [import_sequelize.Op.lt]: toDate(r[1], { ctx }) }]
100
103
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.8.0-beta.10",
3
+ "version": "1.8.0-beta.12",
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-beta.10",
10
- "@nocobase/utils": "1.8.0-beta.10",
9
+ "@nocobase/logger": "1.8.0-beta.12",
10
+ "@nocobase/utils": "1.8.0-beta.12",
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": "09fe854edfc44f45422fa983093dd34694416c5a"
41
+ "gitHead": "b244f9b23ce35bd75baf7b357c6d53d0fbddf3be"
42
42
  }