Multiple `onConflictDoUpdate()`

Is there a cleaner way to do this? I tried case and where in the sql statements in one vs chaining, but that didn't work

const stmt = db.insert(characters).values(chars)
    .onConflictDoUpdate({
        target: characters.id,
        set: {
            name: sql`excluded.name`,
            updatedAt: sql`CURRENT_TIMESTAMP`
        },
        where: sql`excluded.name is not null`
    })
    .onConflictDoUpdate({
        target: characters.id,
        set: {
            level: sql`excluded.level`,
            updatedAt: sql`CURRENT_TIMESTAMP`
        },
        where: sql`excluded.level is not null`
    })
    .onConflictDoUpdate({
        target: characters.id,
        set: {
            factionId: sql`excluded.faction_id`,
            updatedAt: sql`CURRENT_TIMESTAMP`
        },
        where: sql`excluded.faction_id is not null`
    })
    .onConflictDoUpdate({
        target: characters.id,
        set: {
            foreground: sql`excluded.foreground`,
            updatedAt: sql`CURRENT_TIMESTAMP`
        },
        where: sql`excluded.foreground is not null`
    })
    .onConflictDoUpdate({
        target: characters.id,
        set: {
            background: sql`excluded.background`,
            updatedAt: sql`CURRENT_TIMESTAMP`
        },
        where: sql`excluded.background is not null`
    })
Was this page helpful?