Prisma & CockroachDB - push to array

next 12, prisma 4.7.1, CockroachDB When I try to push an item to an array field, I get an error: "Did you mean set?":
await prisma.character.update({
where: {
id: connectionId,
},
data: {
[connectionField]: {
push: characterId,
},
},
});
await prisma.character.update({
where: {
id: connectionId,
},
data: {
[connectionField]: {
push: characterId,
},
},
});
But it works like this:
const character = await prisma.character.findUnique({
where: {
id: connectionId,
},
});

if (character) {
character[connectionField].push(characterId);

const updatedCharacter = await prisma.character.update({
where: {
id: connectionId,
},
data: {
[connectionField]: character[connectionField],
},
});
return updatedCharacter;
}
const character = await prisma.character.findUnique({
where: {
id: connectionId,
},
});

if (character) {
character[connectionField].push(characterId);

const updatedCharacter = await prisma.character.update({
where: {
id: connectionId,
},
data: {
[connectionField]: character[connectionField],
},
});
return updatedCharacter;
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server