@nocobase/actions
Advanced tools
Comparing version 0.5.0-alpha.34 to 0.5.0-alpha.35
@@ -68,4 +68,4 @@ "use strict"; | ||
const _ctx$action$params2 = ctx.action.params, | ||
resourceKey = _ctx$action$params2.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params2.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params2.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params2.resourceIndexAttribute, | ||
_ctx$action$params2$f = _ctx$action$params2.fields, | ||
@@ -76,3 +76,3 @@ fields = _ctx$action$params2$f === void 0 ? [] : _ctx$action$params2$f; | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -79,0 +79,0 @@ context: ctx |
@@ -63,4 +63,4 @@ "use strict"; | ||
resourceName = _ctx$action$params.resourceName, | ||
resourceKey = _ctx$action$params.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params.resourceIndexAttribute, | ||
filter = _ctx$action$params.filter; | ||
@@ -99,6 +99,6 @@ const transaction = yield ctx.db.sequelize.transaction(); | ||
} else if (resourceField instanceof database_1.HASMANY || resourceField instanceof database_1.BELONGSTOMANY) { | ||
const primaryKey = resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute; | ||
const primaryKey = resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute; | ||
const models = yield associated[getAccessor](Object.assign({ | ||
where: resourceKey ? { | ||
[primaryKey]: resourceKey | ||
where: resourceIndex ? { | ||
[primaryKey]: resourceIndex | ||
} : where | ||
@@ -125,6 +125,6 @@ }, commonOptions)); | ||
const primaryKey = resourceKeyAttribute || Model.primaryKeyAttribute; | ||
const primaryKey = resourceIndexAttribute || Model.primaryKeyAttribute; | ||
count = yield Model.destroy(Object.assign(Object.assign({ | ||
where: resourceKey ? { | ||
[primaryKey]: resourceKey | ||
where: resourceIndex ? { | ||
[primaryKey]: resourceIndex | ||
} : where | ||
@@ -131,0 +131,0 @@ }, commonOptions), { |
@@ -73,4 +73,4 @@ "use strict"; | ||
resourceName = _ctx$action$params.resourceName, | ||
resourceKey = _ctx$action$params.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params.resourceIndexAttribute, | ||
_ctx$action$params$fi = _ctx$action$params.fields, | ||
@@ -110,3 +110,3 @@ fields = _ctx$action$params$fi === void 0 ? [] : _ctx$action$params$fi; | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -127,3 +127,3 @@ context: ctx | ||
where: { | ||
[resourceKeyAttribute || Model.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || Model.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -130,0 +130,0 @@ context: ctx |
@@ -84,4 +84,4 @@ "use strict"; | ||
const _ctx$action$params2 = ctx.action.params, | ||
resourceKey = _ctx$action$params2.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params2.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params2.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params2.resourceIndexAttribute, | ||
_ctx$action$params2$f = _ctx$action$params2.fields, | ||
@@ -99,3 +99,3 @@ fields = _ctx$action$params2$f === void 0 ? [] : _ctx$action$params2$f; | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -102,0 +102,0 @@ context: ctx |
@@ -68,4 +68,4 @@ "use strict"; | ||
const _ctx$action$params2 = ctx.action.params, | ||
resourceKey = _ctx$action$params2.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params2.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params2.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params2.resourceIndexAttribute, | ||
_ctx$action$params2$f = _ctx$action$params2.fields, | ||
@@ -76,3 +76,3 @@ fields = _ctx$action$params2$f === void 0 ? [] : _ctx$action$params2$f; | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -79,0 +79,0 @@ context: ctx |
@@ -73,10 +73,10 @@ "use strict"; | ||
resourceName = _b.resourceName, | ||
resourceKey = _b.resourceKey, | ||
resourceIndex = _b.resourceIndex, | ||
resourceField = _b.resourceField, | ||
associatedName = _b.associatedName, | ||
associatedKey = _b.associatedKey, | ||
associatedIndex = _b.associatedIndex, | ||
associated = _b.associated, | ||
_b$values = _b.values, | ||
values = _b$values === void 0 ? {} : _b$values, | ||
others = __rest(_b, ["resourceName", "resourceKey", "resourceField", "associatedName", "associatedKey", "associated", "values"]); | ||
others = __rest(_b, ["resourceName", "resourceIndex", "resourceField", "associatedName", "associatedIndex", "associated", "values"]); | ||
@@ -96,3 +96,3 @@ if (associated && resourceField) { | ||
const primaryKeyAttribute = Model.primaryKeyAttribute; | ||
const sourceId = others.sourceId || resourceKey; | ||
const sourceId = others.sourceId || resourceIndex; | ||
const field = others.sortField || (values === null || values === void 0 ? void 0 : values.sortField) || (values === null || values === void 0 ? void 0 : values.field) || 'sort'; | ||
@@ -127,3 +127,3 @@ const targetId = others.targetId || (values === null || values === void 0 ? void 0 : values.targetId) || ((_a = values === null || values === void 0 ? void 0 : values.target) === null || _a === void 0 ? void 0 : _a[primaryKeyAttribute]); | ||
if (associated && resourceField instanceof database_1.HASMANY) { | ||
where[resourceField.options.foreignKey] = associatedKey; | ||
where[resourceField.options.foreignKey] = associatedIndex; | ||
} | ||
@@ -130,0 +130,0 @@ |
@@ -85,4 +85,4 @@ "use strict"; | ||
const _ctx$action$params2 = ctx.action.params, | ||
resourceKey = _ctx$action$params2.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params2.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params2.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params2.resourceIndexAttribute, | ||
_ctx$action$params2$f = _ctx$action$params2.fields, | ||
@@ -98,3 +98,3 @@ fields = _ctx$action$params2$f === void 0 ? [] : _ctx$action$params2$f; | ||
if (m1 && m1[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute] == resourceKey) { | ||
if (m1 && m1[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute] == resourceIndex) { | ||
ctx.body = yield associated[setAccessor](null); | ||
@@ -104,3 +104,3 @@ } else { | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -114,3 +114,3 @@ context: ctx | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -127,3 +127,3 @@ context: ctx | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
}, | ||
@@ -130,0 +130,0 @@ context: ctx |
@@ -83,4 +83,4 @@ "use strict"; | ||
resourceName = _ctx$action$params.resourceName, | ||
resourceKey = _ctx$action$params.resourceKey, | ||
resourceKeyAttribute = _ctx$action$params.resourceKeyAttribute, | ||
resourceIndex = _ctx$action$params.resourceIndex, | ||
resourceIndexAttribute = _ctx$action$params.resourceIndexAttribute, | ||
fields = _ctx$action$params.fields, | ||
@@ -119,3 +119,3 @@ data = _ctx$action$params.values; | ||
where: { | ||
[resourceKeyAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || resourceField.options.targetKey || TargetModel.primaryKeyAttribute]: resourceIndex | ||
} | ||
@@ -139,3 +139,3 @@ })), | ||
[foreignKey]: associated[sourceKey], | ||
[otherKey]: resourceKey | ||
[otherKey]: resourceIndex | ||
}, | ||
@@ -160,3 +160,3 @@ transaction | ||
where: { | ||
[resourceKeyAttribute || Model.primaryKeyAttribute]: resourceKey | ||
[resourceIndexAttribute || Model.primaryKeyAttribute]: resourceIndex | ||
} | ||
@@ -163,0 +163,0 @@ })); |
@@ -65,6 +65,6 @@ "use strict"; | ||
associatedName = _ctx$action$params.associatedName, | ||
associatedKey = _ctx$action$params.associatedKey, | ||
associatedIndex = _ctx$action$params.associatedIndex, | ||
resourceName = _ctx$action$params.resourceName; | ||
if (!associatedName || !associatedKey) { | ||
if (!associatedName || !associatedIndex) { | ||
return next(); | ||
@@ -96,3 +96,3 @@ } | ||
where: { | ||
[key]: associatedKey | ||
[key]: associatedIndex | ||
} | ||
@@ -99,0 +99,0 @@ }); |
{ | ||
"name": "@nocobase/actions", | ||
"version": "0.5.0-alpha.34", | ||
"version": "0.5.0-alpha.35", | ||
"description": "", | ||
@@ -10,7 +10,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"@nocobase/database": "^0.5.0-alpha.34", | ||
"@nocobase/resourcer": "^0.5.0-alpha.34" | ||
"@nocobase/database": "^0.5.0-alpha.35", | ||
"@nocobase/resourcer": "^0.5.0-alpha.35" | ||
}, | ||
"devDependencies": { | ||
"@nocobase/test": "^0.5.0-alpha.34" | ||
"@nocobase/test": "^0.5.0-alpha.35" | ||
}, | ||
@@ -22,3 +22,3 @@ "repository": { | ||
}, | ||
"gitHead": "11cded6153bab633fb0b7415c33b4c3c369c2427" | ||
"gitHead": "2b81a6af327ee784a6943aff6e028fde3298dec9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
160987