I am using strapi version 4.2.0 and I am trying to use query engine’s createMany() method but it doesn’t store foreign keys properly.
const profile1 = { group: 1 };
const profile2 = { group: 2 };
const result = await strapi.db.query("api::profile.profile").createMany({
data: [ profile1, profile2 ]
})
Here group
is a foreign key to another model. This creates two profile rows but the foreign keys are empty. But if I add them one by one using create()
it is stored properly.
I also tried passing the group object instead of its id but it has the same result:
const profile1 = { group: groupObjectFromDb1 };
const profile2 = { group: groupObjectFromDb2 };
const result = await strapi.db.query("api::profile.profile").createMany({
data: [ profile1, profile2 ]
})