Muhannad
Muhannad
Explore posts from servers
DTDrizzle Team
Created by Muhannad on 3/8/2024 in #help
Insert multiple rows return order
Is the return value of an "insert many" operation ordered in the same order of the items passed to it
const result = await db.insert(myTable).values([{id:1},{id:2}]).returning({ id: myTable.id })
const result = await db.insert(myTable).values([{id:1},{id:2}]).returning({ id: myTable.id })
Can I be sure that result[0] has id 1 and result[1] has id 2?
1 replies
DTDrizzle Team
Created by Muhannad on 9/7/2023 in #help
pgEnum in multiple tables
How should I use the same enum in multiple tables? For example I have this enum in:
const ROLES = ['owner', 'admin', 'editor', 'viewer'] as const
const roleEnum = pgEnum('role', ROLES)
// in table I use it like this:
role: roleEnum('role')
const ROLES = ['owner', 'admin', 'editor', 'viewer'] as const
const roleEnum = pgEnum('role', ROLES)
// in table I use it like this:
role: roleEnum('role')
If I want to use the same role enum in another table should I use the same pgEnum `const roleEnum = pgEnum('role', ROLES) i.e. import it? Or create the same pgEnum again?
2 replies