Dan
Dan
Explore posts from servers
TtRPC
Created by Trader Launchpad on 11/9/2023 in #❓-help
[How To?] Create a record in database on form submission...
Just searching through for something else but stumbled across your message. Example of sqlite table for cloudflare:
export const times = sqliteTable('times', {
id: text('id')
.notNull()
.primaryKey()
.$default(() => crypto.randomUUID()),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.$default(() => new Date()),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.$default(() => new Date()),
location: text('location').notNull(),
content: text('content', { mode: 'json' }).notNull().$type<TimeContent>(),
});
export const times = sqliteTable('times', {
id: text('id')
.notNull()
.primaryKey()
.$default(() => crypto.randomUUID()),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.$default(() => new Date()),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.$default(() => new Date()),
location: text('location').notNull(),
content: text('content', { mode: 'json' }).notNull().$type<TimeContent>(),
});
It's not as performant as uuid on postgres but the purpose to use uuid in my case is to avoid that people can guess a sequence. If there would be a need for a sortable id based on time, you could use uuidv7, there are some implementations, e.g. https://github.com/LiosK/uuidv7, but they are roughly 4x slower than uuid4.
5 replies
CDCloudflare Developers
Created by Dan on 12/12/2023 in #workers-help
Global vars
Does it impact worker's performance when I opt-in to node compatibility? I see that the process needs to be imported and env values copied. How is it different from creating a module with custom export const env = {}; ?
6 replies
CDCloudflare Developers
Created by Dan on 12/12/2023 in #workers-help
Global vars
Thanks for the clarification!
6 replies
DTDrizzle Team
Created by rodrigo on 7/22/2023 in #help
Insert multiple rows + onConflictDoUpdate
Yes, I'm using it like this:
const result = await ctx.db
.insert(Regions)
.values(regionValues)
.onConflictDoUpdate({
target: Regions.id,
set: {
name: sql`EXCLUDED.name`,
en: sql`EXCLUDED.en`,
de: sql`EXCLUDED.de`,
parentId,
},
})
.returning();
const result = await ctx.db
.insert(Regions)
.values(regionValues)
.onConflictDoUpdate({
target: Regions.id,
set: {
name: sql`EXCLUDED.name`,
en: sql`EXCLUDED.en`,
de: sql`EXCLUDED.de`,
parentId,
},
})
.returning();
4 replies
DTDrizzle Team
Created by Dan on 6/17/2023 in #help
How to do migrations that require data changes?
That's exactly what I was looking for, thank you!
5 replies