Timo
Timo
DTDrizzle Team
Created by Timo on 8/16/2024 in #help
Delete an item from an object
I want to get rid of the password in user records. How to delete the password from a user record?
1 replies
DTDrizzle Team
Created by Timo on 7/22/2024 in #help
What will .array() do?
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
fellows: uuid('fellow_ids').array(),
createdAt: timestamp('created_at').notNull().defaultNow(),
updatedAt: timestamp('updated_at').notNull().defaultNow()
})
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
fellows: uuid('fellow_ids').array(),
createdAt: timestamp('created_at').notNull().defaultNow(),
updatedAt: timestamp('updated_at').notNull().defaultNow()
})
1 replies
DTDrizzle Team
Created by Timo on 7/19/2024 in #help
Query causes error
const user = await database.query.users.findFirst({
where: eq(users.id, id),
with: {
links: true,
reactions: true,
friendships: true
}
})
const user = await database.query.users.findFirst({
where: eq(users.id, id),
with: {
links: true,
reactions: true,
friendships: true
}
})
Is there something wrong? Thanks.
32 replies
DTDrizzle Team
Created by Timo on 7/14/2024 in #help
Overwriting Schema Defaults
await database.insert(users).values([
{
name: ADMIN_NAME!,
slug: ADMIN_SLUG!,
email: ADMIN_EMAIL!,
password: ADMIN_PASSWORD!,
role: 'ADMIN',
active: true
}
])
await database.insert(users).values([
{
name: ADMIN_NAME!,
slug: ADMIN_SLUG!,
email: ADMIN_EMAIL!,
password: ADMIN_PASSWORD!,
role: 'ADMIN',
active: true
}
])
the values function is marked with an error, because I set role and active, which already have a value due to their default value in the schema. What can I do about that?
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
name: varchar('name', { length: 256 }).notNull(),
slug: varchar('slug', { length: 256 }).notNull().unique(),
biography: text('biography'),
email: varchar('email', { length: 256 }).notNull(),
password: varchar('password', { length: 256 }).notNull(),
role: role('role').notNull().default('STANDARD'),
active: boolean('active').notNull().default(false),
createdAt: timestamp('created_at').notNull().defaultNow(),
updatedAt: timestamp('updated_at').notNull().defaultNow()
})
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
name: varchar('name', { length: 256 }).notNull(),
slug: varchar('slug', { length: 256 }).notNull().unique(),
biography: text('biography'),
email: varchar('email', { length: 256 }).notNull(),
password: varchar('password', { length: 256 }).notNull(),
role: role('role').notNull().default('STANDARD'),
active: boolean('active').notNull().default(false),
createdAt: timestamp('created_at').notNull().defaultNow(),
updatedAt: timestamp('updated_at').notNull().defaultNow()
})
Thank you. Timo
3 replies