kingtimm
kingtimm
Explore posts from servers
DTDrizzle Team
Created by kingtimm on 11/19/2024 in #help
Conditionally throw error on D1 Batch Process
In Cloudflare D1, we do not have db.transaction and instead rely on db.batch. Cloudflare D1 rolls back if a statement in the batch errors. It is working ok, but I was wondering if it was possible to throw an error if a select returns zero results. E.g. checking if the user is owner of a certain record before proceeding into other updates
db.select().from(tables.lists).where(and(
eq(tables.lists.owner, userId),
eq(tables.lists.id, id)
)),
db.select().from(tables.lists).where(and(
eq(tables.lists.owner, userId),
eq(tables.lists.id, id)
)),
1 replies
NNuxt
Created by kingtimm on 3/9/2024 in #❓・help
Server Bundle Size with Clerk
Im not too familiar with the server bundle size. I've gotten it down to 985kB against Vercel's 1MB limit. I'm using vue-clerk and h3-clerk which instruct adding them to build.transpile. That seems to add most of the size. Any tips to try to reduce the server bundle size? nuxi analyze doesn't provide much detail into the server.mjs file
1 replies
DTDrizzle Team
Created by kingtimm on 9/21/2023 in #help
Simple ForeignKey With statement not working
Hi - I am attempting to use a with statement on a query and am getting this error: Cannot read properties of undefined (reading 'referencedTable') Here's the query:
await db.query.faves.findMany({
with: {
firstName: true,
middleName: true
}
await db.query.faves.findMany({
with: {
firstName: true,
middleName: true
}
Here is the schema
export const names = sqliteTable('names', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
})

export type Name = InferSelectModel<typeof names>

export const faves = sqliteTable('faves', {
id: integer('id').primaryKey(),
firstName: integer('first_name_id').references(() => names.id),
middleName: integer('middle_name_id').references(() => names.id),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
})
export const names = sqliteTable('names', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
})

export type Name = InferSelectModel<typeof names>

export const faves = sqliteTable('faves', {
id: integer('id').primaryKey(),
firstName: integer('first_name_id').references(() => names.id),
middleName: integer('middle_name_id').references(() => names.id),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
})
Do I need to add a relationship? From the docs - it seemed like the foreignkey would be enough. The "Faves" table is just a record of favorite combinations from the "Names" table.
2 replies