@nocobase/database 1.6.0-alpha.10 → 1.6.0-alpha.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.
@@ -43,6 +43,7 @@ export interface CollectionOptions extends Omit<ModelOptions, 'name' | 'hooks'>
43
43
  isThrough?: boolean;
44
44
  filterTargetKey?: string | string[];
45
45
  fields?: FieldOptions[];
46
+ fieldSort?: string[];
46
47
  model?: string | ModelStatic<Model>;
47
48
  repository?: string | RepositoryType;
48
49
  sortable?: CollectionSortable;
@@ -38,7 +38,7 @@ const _ToManyInterface = class _ToManyInterface extends import_base_interface.Ba
38
38
  }
39
39
  str = `${str}`.trim();
40
40
  const items = str.split(",");
41
- const { filterKey, targetCollection, transaction } = ctx;
41
+ const { filterKey, targetCollection, transaction, field } = ctx;
42
42
  const targetInstances = await targetCollection.repository.find({
43
43
  filter: {
44
44
  [filterKey]: items
@@ -51,7 +51,17 @@ const _ToManyInterface = class _ToManyInterface extends import_base_interface.Ba
51
51
  }
52
52
  });
53
53
  const primaryKeyAttribute = targetCollection.model.primaryKeyAttribute;
54
- return targetInstances.map((targetInstance) => targetInstance[primaryKeyAttribute]);
54
+ const targetKey = field.options.targetKey;
55
+ const values = targetInstances.map((targetInstance) => {
56
+ const result = {
57
+ [targetKey]: targetInstance[targetKey]
58
+ };
59
+ if (targetKey !== primaryKeyAttribute) {
60
+ result[primaryKeyAttribute] = targetInstance[primaryKeyAttribute];
61
+ }
62
+ return result;
63
+ });
64
+ return values;
55
65
  }
56
66
  };
57
67
  __name(_ToManyInterface, "ToManyInterface");
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.6.0-alpha.10",
3
+ "version": "1.6.0-alpha.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.6.0-alpha.10",
10
- "@nocobase/utils": "1.6.0-alpha.10",
9
+ "@nocobase/logger": "1.6.0-alpha.12",
10
+ "@nocobase/utils": "1.6.0-alpha.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": "8ba8204282be7bf6674ef427fdbe31caa65977d5"
41
+ "gitHead": "b13c1c22daf71b4ec311114a6019c0f061864d9b"
42
42
  }