DoggeSlapper
DoggeSlapper
DTDrizzle Team
Created by DoggeSlapper on 10/28/2024 in #help
Drizzle d1 client seems to be missing
No description
12 replies
DTDrizzle Team
Created by DoggeSlapper on 10/14/2024 in #help
Extend/omit from table schema.
Let's say I have this schema.
export const users = pgTable('users', {
id: serial('id').primaryKey(),
email: varchar('email', { length: 255 }).notNull().unique(),
phone: varchar('phone', { length: 30 }).notNull().unique(),
userName: varchar('user_name', { length: 255 }).notNull(),
firstName: varchar('first_name', { length: 255 }).notNull(),
lastName: varchar('last_name', { length: 255 }).notNull(),
bio: text('bio'),
password: varchar('password', { length: 255 }).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
export const users = pgTable('users', {
id: serial('id').primaryKey(),
email: varchar('email', { length: 255 }).notNull().unique(),
phone: varchar('phone', { length: 30 }).notNull().unique(),
userName: varchar('user_name', { length: 255 }).notNull(),
firstName: varchar('first_name', { length: 255 }).notNull(),
lastName: varchar('last_name', { length: 255 }).notNull(),
bio: text('bio'),
password: varchar('password', { length: 255 }).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
is there a way to create a copy the schema without password column?
2 replies
DTDrizzle Team
Created by DoggeSlapper on 9/18/2024 in #help
Issue with json object prop query
This will work but I cant make the 'slug' dynamic
// This works
sql`categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object('slug', ${filter.value}::text))`;

// dont work (where categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object($1, $2::text))',
// params: [ 'slug', 'cabello' ]
// error: could not determine data type of parameter $1)
sql`categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object(${filter.column}, ${filter.value}::text))`;
// doesnt work either it get replaced as "slug" so I get column reference "slug" is ambiguous

sql`categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object(${sql.identifier(filter.column)}, ${filter.value}::text))`
// This works
sql`categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object('slug', ${filter.value}::text))`;

// dont work (where categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object($1, $2::text))',
// params: [ 'slug', 'cabello' ]
// error: could not determine data type of parameter $1)
sql`categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object(${filter.column}, ${filter.value}::text))`;
// doesnt work either it get replaced as "slug" so I get column reference "slug" is ambiguous

sql`categories_subquery.categories::jsonb @> jsonb_build_array(jsonb_build_object(${sql.identifier(filter.column)}, ${filter.value}::text))`
2 replies