@nocobase/plugin-data-source-main 1.6.0-alpha.5 → 1.6.0-alpha.6

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.
@@ -8,13 +8,13 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.6.0-alpha.5",
12
- "@nocobase/database": "1.6.0-alpha.5",
13
- "@nocobase/plugin-error-handler": "1.6.0-alpha.5",
14
- "@nocobase/server": "1.6.0-alpha.5",
11
+ "@nocobase/client": "1.6.0-alpha.6",
12
+ "@nocobase/database": "1.6.0-alpha.6",
13
+ "@nocobase/plugin-error-handler": "1.6.0-alpha.6",
14
+ "@nocobase/server": "1.6.0-alpha.6",
15
15
  "lodash": "4.17.21",
16
- "@nocobase/test": "1.6.0-alpha.5",
17
- "@nocobase/utils": "1.6.0-alpha.5",
16
+ "@nocobase/test": "1.6.0-alpha.6",
17
+ "@nocobase/utils": "1.6.0-alpha.6",
18
18
  "sequelize": "6.35.2",
19
19
  "dayjs": "1.11.10"
20
20
  };
@@ -83,7 +83,7 @@ function afterCreateForForeignKeyField(db) {
83
83
  }
84
84
  return data;
85
85
  }
86
- async function createFieldIfNotExists({ values, transaction }) {
86
+ async function createFieldIfNotExists({ values, transaction, interfaceType = null }) {
87
87
  const { collectionName, name } = values;
88
88
  if (!collectionName || !name) {
89
89
  throw new Error(`field options invalid`);
@@ -104,13 +104,17 @@ function afterCreateForForeignKeyField(db) {
104
104
  instance.set("isForeignKey", true);
105
105
  await instance.save({ transaction });
106
106
  } else {
107
- const creatInstance = await r.create({
107
+ const createOptions = {
108
108
  values: {
109
109
  isForeignKey: true,
110
110
  ...values
111
111
  },
112
112
  transaction
113
- });
113
+ };
114
+ if (interfaceType === "m2o") {
115
+ createOptions["context"] = {};
116
+ }
117
+ const creatInstance = await r.create(createOptions);
114
118
  creatInstance.set("sort", 1);
115
119
  await creatInstance.save({ transaction });
116
120
  }
@@ -149,13 +153,15 @@ function afterCreateForForeignKeyField(db) {
149
153
  collectionName: target,
150
154
  ...values
151
155
  },
156
+ interfaceType,
152
157
  transaction
153
158
  });
154
159
  } else if (["obo", "m2o"].includes(interfaceType)) {
155
160
  const values = generateFkOptions(collectionName, foreignKey);
156
161
  await createFieldIfNotExists({
157
162
  values: { collectionName, ...values },
158
- transaction
163
+ transaction,
164
+ interfaceType
159
165
  });
160
166
  } else if (["linkTo", "m2m"].includes(interfaceType)) {
161
167
  if (type !== "belongsToMany") {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "数据源:主数据库",
5
5
  "description": "NocoBase main database, supports relational databases such as PostgreSQL, MySQL, MariaDB and so on.",
6
6
  "description.zh-CN": "NocoBase 主数据库,支持 PostgreSQL、MySQL、MariaDB 等关系型数据库。",
7
- "version": "1.6.0-alpha.5",
7
+ "version": "1.6.0-alpha.6",
8
8
  "main": "./dist/server/index.js",
9
9
  "homepage": "https://docs.nocobase.com/handbook/data-source-main",
10
10
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/data-source-main",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/test": "1.x",
23
23
  "@nocobase/utils": "1.x"
24
24
  },
25
- "gitHead": "b600efcab7fef54f1456ef079787f0ab4992e249",
25
+ "gitHead": "485580ad30e5164ead7e15f3b4d219f2bce2caf4",
26
26
  "keywords": [
27
27
  "Data sources"
28
28
  ]