@nocobase/database 2.0.0-alpha.51 → 2.0.0-alpha.53

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.
@@ -26,7 +26,9 @@ export declare class OptionsParser {
26
26
  static appendInheritInspectAttribute(include: any, collection: any): any;
27
27
  isAssociation(key: string): boolean;
28
28
  isAssociationPath(path: string): boolean;
29
- filterByTkToWhereOption(): {};
29
+ filterByTkToWhereOption(): string | number | import("./repository").MultiTargetKey[] | {
30
+ [x: string]: import("./repository").TargetKey;
31
+ };
30
32
  toSequelizeParams(options?: {
31
33
  parseSort?: boolean;
32
34
  }): any;
@@ -41,9 +41,9 @@ __export(options_parser_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(options_parser_exports);
43
43
  var import_lodash = __toESM(require("lodash"));
44
+ var import_qs = __toESM(require("qs"));
44
45
  var import_sequelize = require("sequelize");
45
46
  var import_filter_parser = __toESM(require("./filter-parser"));
46
- var import_qs = __toESM(require("qs"));
47
47
  const debug = require("debug")("noco-database");
48
48
  const _OptionsParser = class _OptionsParser {
49
49
  options;
@@ -96,14 +96,21 @@ const _OptionsParser = class _OptionsParser {
96
96
  if (!filterByTkOption) {
97
97
  return {};
98
98
  }
99
- if (import_lodash.default.isPlainObject(this.options.filterByTk)) {
100
- const where = {};
101
- for (const [key, value] of Object.entries(filterByTkOption)) {
102
- where[key] = value;
103
- }
104
- return where;
99
+ if (Array.isArray(filterByTkOption) && filterByTkOption.length === 0) {
100
+ return {};
105
101
  }
106
102
  const filterTargetKey = this.context.targetKey || this.collection.filterTargetKey;
103
+ if (Array.isArray(filterByTkOption) && Array.isArray(filterTargetKey)) {
104
+ if (!filterByTkOption.every(import_lodash.default.isPlainObject)) {
105
+ throw new Error("filterByTk array item must be plain object");
106
+ }
107
+ return {
108
+ [import_sequelize.Op.or]: filterByTkOption
109
+ };
110
+ }
111
+ if (import_lodash.default.isPlainObject(filterByTkOption)) {
112
+ return filterByTkOption;
113
+ }
107
114
  if (Array.isArray(filterTargetKey)) {
108
115
  throw new Error("multi filter target key value must be object");
109
116
  }
@@ -30,7 +30,7 @@ export interface FilterAble {
30
30
  }
31
31
  export type BaseTargetKey = string | number;
32
32
  export type MultiTargetKey = Record<string, BaseTargetKey>;
33
- export type TargetKey = BaseTargetKey | MultiTargetKey;
33
+ export type TargetKey = BaseTargetKey | MultiTargetKey | MultiTargetKey[];
34
34
  export type TK = TargetKey | TargetKey[];
35
35
  type FieldValue = string | number | bigint | boolean | Date | Buffer | null | FieldValue[] | FilterWithOperator;
36
36
  type Operators = keyof typeof operators & keyof WhereOperators;
package/lib/repository.js CHANGED
@@ -71,8 +71,8 @@ var import_hasmany_repository = require("./relation-repository/hasmany-repositor
71
71
  var import_hasone_repository = require("./relation-repository/hasone-repository");
72
72
  var import_update_associations = require("./update-associations");
73
73
  var import_update_guard = require("./update-guard");
74
- var import_filter_utils = require("./utils/filter-utils");
75
74
  var import_utils2 = require("./utils");
75
+ var import_filter_utils = require("./utils/filter-utils");
76
76
  var import_sequelize2 = require("sequelize");
77
77
  const debug = require("debug")("noco-database");
78
78
  const transaction = (0, import_transaction_decorator.transactionWrapperBuilder)(function() {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "2.0.0-alpha.51",
3
+ "version": "2.0.0-alpha.53",
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": "2.0.0-alpha.51",
10
- "@nocobase/utils": "2.0.0-alpha.51",
9
+ "@nocobase/logger": "2.0.0-alpha.53",
10
+ "@nocobase/utils": "2.0.0-alpha.53",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -39,5 +39,5 @@
39
39
  "url": "git+https://github.com/nocobase/nocobase.git",
40
40
  "directory": "packages/database"
41
41
  },
42
- "gitHead": "a1e34dd97f370d54f3d80a6b83ab7ddb9c72dc18"
42
+ "gitHead": "ff30cf8261f5a97b3f24c3752af5bbc564167b37"
43
43
  }