xvx
xvx
Explore posts from servers
DTDrizzle Team
Created by xvx on 6/12/2024 in #help
How to dynamically set a row value using data from a JS object? (onConflictDoUpdate)
I am: - Checking if a row already exists - If it doesn't: Insert the data array's object - If it exists: Update the price column - The issue is I'm not sure how to set a row to the relevant object in my data array
const data = [
{organisationId: "ABCD", accountId: "001", price: "120000"},
{organisationId: "EFGH", accountId: "002", price: "59000"},
];

await db
.insert(myTable)
.values(data)
.onConflictDoUpdate({
target: [myTable.organisationId, myTable.financialAccountId],
set: data[0], // Putting [0] works but how to dynamically set the value to the relevant object in data array?
});
const data = [
{organisationId: "ABCD", accountId: "001", price: "120000"},
{organisationId: "EFGH", accountId: "002", price: "59000"},
];

await db
.insert(myTable)
.values(data)
.onConflictDoUpdate({
target: [myTable.organisationId, myTable.financialAccountId],
set: data[0], // Putting [0] works but how to dynamically set the value to the relevant object in data array?
});
13 replies
HHono
Created by xvx on 4/8/2024 in #help
Why use Hono for Next.js backend (route handlers)?
I'm creating a full-stack web app and probably using Next.js API/route handler: https://nextjs.org/docs/app/building-your-application/routing/route-handlers I saw that Hono has a page about supporting it: https://hono.dev/getting-started/vercel#_2-hello-world I'm curious what the point of using Hono in Next.js' route handlers is, instead of just using Next.js' default route handler (using 2 solutions (both support HTTP requests/responses) instead of simply 1)? Is it because the developer may prefer Hono's syntax? (FYI I'm not very familiar with backend development)
3 replies