onConflictDoNothing does not exist on planetscale client

i am getting an "Property onConflictDoNothing does not exist on type" on the following script....
export async function lookupNationalitySeed(client: DbClient) {
await client.insert(lookupNationality).values(
data.map((nationality) => ({
id: ulid(),
name: nationality,
slug: paramCase(nationality),
})),
).onConflictDoNothing()
}
export async function lookupNationalitySeed(client: DbClient) {
await client.insert(lookupNationality).values(
data.map((nationality) => ({
id: ulid(),
name: nationality,
slug: paramCase(nationality),
})),
).onConflictDoNothing()
}
the client is a type of PlanetScaleDatabase<typeof schema> the only typesafe method i get is onDuplicateKeyUpdate
5 Replies
BinaryArtifex
BinaryArtifexOP16mo ago
oh hang on....is this what im looking for? this doesn't appear to be in the docs....
export async function lookupNationalitySeed(client: DbClient) {
await client
.insert(lookupNationality)
.ignore() // <<------
.values(
data.map((nationality) => ({
id: ulid(),
name: nationality,
slug: paramCase(nationality),
})),
);
}
export async function lookupNationalitySeed(client: DbClient) {
await client
.insert(lookupNationality)
.ignore() // <<------
.values(
data.map((nationality) => ({
id: ulid(),
name: nationality,
slug: paramCase(nationality),
})),
);
}
Monk
Monk16mo ago
Did this .ignore() end up being what you were looking for @frostyghostman ? Just ran into this myself.
Josh
Josh16mo ago
bumping this, i just ran into it aswell.
Josh
Josh16mo ago
ignore does indeed work. It just adds the ignore keyword to the sql query, with more info on it found here
Stack Overflow
"INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"
While executing an INSERT statement with many rows, I want to skip duplicate entries that would otherwise cause failure. After some research, my options appear to be the use of either: ON DUPLICAT...
BinaryArtifex
BinaryArtifexOP15mo ago
oh nice, forgot i even asked this and went back to ask again and found my original question answered haha
Want results from more Discord servers?
Add your server