Strapi:React:无法读取未定义的 属性 'associations'
Strapi: React: Cannot read property 'associations' of undefined
目前正在尝试上传图像并将其连接到现有条目。
现有条目的架构是
{
"name": "page rows",
"description": "",
"connection": "default",
"kind": "collectionType",
"collectionName": "page_rows",
"attributes": {
"row": {
"type": "json"
},
"images": {
"type": "media",
"multiple": true,
"required": false,
"allowedTypes": [
"images"
]
}
}
},
我使用
上传了一张图片
export const formatEntryUpload = (file, entryModel, entryID, entryField, entryPlugin = null) => {
const entryUpload = new FormData();
entryUpload.append('files', file);
entryUpload.append('ref', entryModel);
entryUpload.append('refId', entryID);
entryUpload.append('field', entryField);
if(entryPlugin) {
entryUpload.append('source', entryPlugin);
}
return entryUpload;
};
在我填写调用函数的地方
formatEntryUpload ( file, "page_rows", id, "images", "users-permissions");
然而,当我这样做时,出现以下错误。
[2021-02-07T21:01:35.334Z] error TypeError: Cannot read property 'associations' of undefined
at /srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:250:43
at Array.forEach (<anonymous>)
at /srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:235:20
at Array.reduce (<anonymous>)
at Function.update [as updateRelations] (/srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:97:68)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.add (/srv/app/node_modules/strapi-plugin-upload/services/Upload.js:253:17)
at async Promise.all (index 0)
at async Object.upload (/srv/app/node_modules/strapi-plugin-upload/services/Upload.js:105:12)
at async Object.upload (/srv/app/node_modules/strapi-plugin-upload/controllers/Upload.js:82:18)
at async /srv/app/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:70:22
at async module.exports (/srv/app/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:97:3)
at async /srv/app/node_modules/strapi-utils/lib/policy.js:52:5
[2021-02-07T21:01:35.334Z] debug POST /upload (564 ms) 500
图片已成功上传,但与条目没有关联。我需要更改什么才能将图像与条目相关联?
将“page_rows”更改为“page_row”
它帮助了我
formatEntryUpload ( file, "page_rows", id, "images", "users-permissions") =>
formatEntryUpload ( file, "page_row", id, "images", "users-permissions");
目前正在尝试上传图像并将其连接到现有条目。
现有条目的架构是
{
"name": "page rows",
"description": "",
"connection": "default",
"kind": "collectionType",
"collectionName": "page_rows",
"attributes": {
"row": {
"type": "json"
},
"images": {
"type": "media",
"multiple": true,
"required": false,
"allowedTypes": [
"images"
]
}
}
},
我使用
上传了一张图片export const formatEntryUpload = (file, entryModel, entryID, entryField, entryPlugin = null) => {
const entryUpload = new FormData();
entryUpload.append('files', file);
entryUpload.append('ref', entryModel);
entryUpload.append('refId', entryID);
entryUpload.append('field', entryField);
if(entryPlugin) {
entryUpload.append('source', entryPlugin);
}
return entryUpload;
};
在我填写调用函数的地方
formatEntryUpload ( file, "page_rows", id, "images", "users-permissions");
然而,当我这样做时,出现以下错误。
[2021-02-07T21:01:35.334Z] error TypeError: Cannot read property 'associations' of undefined
at /srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:250:43
at Array.forEach (<anonymous>)
at /srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:235:20
at Array.reduce (<anonymous>)
at Function.update [as updateRelations] (/srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:97:68)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.add (/srv/app/node_modules/strapi-plugin-upload/services/Upload.js:253:17)
at async Promise.all (index 0)
at async Object.upload (/srv/app/node_modules/strapi-plugin-upload/services/Upload.js:105:12)
at async Object.upload (/srv/app/node_modules/strapi-plugin-upload/controllers/Upload.js:82:18)
at async /srv/app/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:70:22
at async module.exports (/srv/app/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:97:3)
at async /srv/app/node_modules/strapi-utils/lib/policy.js:52:5
[2021-02-07T21:01:35.334Z] debug POST /upload (564 ms) 500
图片已成功上传,但与条目没有关联。我需要更改什么才能将图像与条目相关联?
将“page_rows”更改为“page_row” 它帮助了我
formatEntryUpload ( file, "page_rows", id, "images", "users-permissions") =>
formatEntryUpload ( file, "page_row", id, "images", "users-permissions");