Hi!
First of all, thanks, the upload part works great!
But setting the relation just wont work for me…
SqliteError: insert into `files_related_morphs` (`0`, `1`, `10`, `11`, `12`, `13`, `14`, `2`, `3`,
`4`, `5`, `6`, `7`, `8`, `9`, `file_id`, `related_id`, `related_type`) values ('p', 'r', 'c', 't',
'u', 'r', 'e', 'o', 'f', 'i', 'l', 'e', '_', 'p', 'i', 19, '98', 'plugin::users-permissions.user')
- table files_related_morphs has no column named 0
at Database.prepare (...node_modules\better-sqlite3\lib\methods\wrappers.js:5:21)
This is my code:
const uploadAndLinkDocument = async () => {
const config = strapi.config.get("plugin.upload");
const entity = {
name: `useravatar-${event.params.data.username}`,
hash: event.result.id,
ext: ".jpg",
mime: "image/jpeg",
size: response.data.length,
provider: config.provider,
};
entity.related = [
{
id: `${event.result.id}`,
__type: "plugin::users-permissions.user",
__pivot: "profile_picture",
},
];
entity.getStream = () => Readable.from(response.data);
await strapi.plugin("upload").service("provider").upload(entity);
const fileValues = { ...entity };
const res = await strapi.query("plugin::upload.file").create({ data: fileValues });
return res;
};
Do you perhaps have a clue what’s wrong here?
If I remove __pivot: "profile_picture", the relation almost gets set correctly:
![]()
Only field and order columns are null.