yehia
yehia
Explore posts from servers
DTDrizzle Team
Created by yehia on 7/12/2024 in #help
Not null must have default value as well?
Noob question. Does a "not null" value have to have a default value? For some reason it seems like the case. This insert snippet is not working. and giving me a Object literal may only specify known properties, and email does not exist in type and Object literal may only specify known properties, and first_name does not exist in type When I comment out phone and email from my schema/make them both nullable/add a default value it doesn't give me this error.
async signup(dto: AuthDto) {
const hash = await argon.hash(dto.password);
const user = await this.dbService.db
.insert(schema.users)
.values({
email: dto.email,
phone: dto.phone
password_hash: hash,
first_name: 'test',
last_name: 'user',
role: schema.userRoleEnum.enumValues[0],
created_at: new Date(),
})
.returning();
}
async signup(dto: AuthDto) {
const hash = await argon.hash(dto.password);
const user = await this.dbService.db
.insert(schema.users)
.values({
email: dto.email,
phone: dto.phone
password_hash: hash,
first_name: 'test',
last_name: 'user',
role: schema.userRoleEnum.enumValues[0],
created_at: new Date(),
})
.returning();
}
schema.ts
import {
pgTable,
text,
uuid,
boolean,
timestamp,
pgEnum,
varchar,
} from 'drizzle-orm/pg-core';

export const userRoleEnum = pgEnum('user_role', [
'user',
'admin',
'branch_manager',
'restaurant_owner',
]);

export const users = pgTable('users', {
id: uuid('id').notNull().defaultRandom().primaryKey(),
email: varchar('email', { length: 255 }).unique(),
phone: varchar('phone', { length: 20 }).notNull().unique(),
first_name: varchar('first_name', { length: 50 }),
last_name: varchar('last_name', { length: 50 }),
email_verified: boolean('email_verified').default(false),
phone_verified: boolean('phone_verified').default(false),
created_at: timestamp('created_at').notNull().defaultNow(),
role: userRoleEnum('role').notNull().default('user'),
password_hash: text('password_hash').notNull(),
});
import {
pgTable,
text,
uuid,
boolean,
timestamp,
pgEnum,
varchar,
} from 'drizzle-orm/pg-core';

export const userRoleEnum = pgEnum('user_role', [
'user',
'admin',
'branch_manager',
'restaurant_owner',
]);

export const users = pgTable('users', {
id: uuid('id').notNull().defaultRandom().primaryKey(),
email: varchar('email', { length: 255 }).unique(),
phone: varchar('phone', { length: 20 }).notNull().unique(),
first_name: varchar('first_name', { length: 50 }),
last_name: varchar('last_name', { length: 50 }),
email_verified: boolean('email_verified').default(false),
phone_verified: boolean('phone_verified').default(false),
created_at: timestamp('created_at').notNull().defaultNow(),
role: userRoleEnum('role').notNull().default('user'),
password_hash: text('password_hash').notNull(),
});
13 replies
TTCTheo's Typesafe Cult
Created by yehia on 7/16/2023 in #questions
Sending emails
Hey, wondering whats the best option to send emails to users. Right now sending emails for verifying the users email. Currently testing out gmail smtp, but I'm hearing about resend and sendgrid, etc. Why would I go with these services and not gmail smtp considering how easy it is to setup with something like nodemailer?
6 replies
CDCloudflare Developers
Created by yehia on 7/5/2023 in #workers-help
Sveltekit - mongoose - serverless mongodb
Noob question. I'm using the mongodb serverless database. Does this mean I can use cloudflare workers in my sveltekit app? Or is it not possible since node isn't available.
2 replies