Ben Quan
Ben Quan
DTDrizzle Team
Created by Ben Quan on 11/4/2024 in #help
Semicolon separated emails using drizzle-zod.
I have the following Schema definition for drizzle-zod:
export const RegistroSchema = createSelectSchema(registro, {
correo: (schema) => schema.correo.email(),
retencionRenta: (schema) => schema.retencionRenta.optional(),
retencionIVA: (schema) => schema.retencionIVA.optional()
});
export const RegistroSchema = createSelectSchema(registro, {
correo: (schema) => schema.correo.email(),
retencionRenta: (schema) => schema.retencionRenta.optional(),
retencionIVA: (schema) => schema.retencionIVA.optional()
});
I want to change the email verification from a single to a multi email verification I have an idea of the required zod definition
z.object({
factoryEmail: z
.string()
.refine((emailValue) => emailValue.split(";").every((item) => z.string().email().safeParse(item).success)),
});
z.object({
factoryEmail: z
.string()
.refine((emailValue) => emailValue.split(";").every((item) => z.string().email().safeParse(item).success)),
});
but I am not sure how to represent that inside ResitroShema (for the field: correo)?
3 replies
DTDrizzle Team
Created by Ben Quan on 8/8/2023 in #help
Simple relational query in sqlite
I am trying to follow the documents but using BetterSqlite3. I have the schema shown in https://orm.drizzle.team/docs/rqb:
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { relations } from 'drizzle-orm';

export const users = sqliteTable('users', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
});

export const usersRelations = relations(users, ({ many }) => ({
posts: many(posts)
}));

export const posts = sqliteTable('posts', {
id: integer('id').primaryKey(),
content: text('content').notNull(),
authorId: integer('author_id').notNull(),
});

export const postsRelations = relations(posts, ({ one }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
}));
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { relations } from 'drizzle-orm';

export const users = sqliteTable('users', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
});

export const usersRelations = relations(users, ({ many }) => ({
posts: many(posts)
}));

export const posts = sqliteTable('posts', {
id: integer('id').primaryKey(),
content: text('content').notNull(),
authorId: integer('author_id').notNull(),
});

export const postsRelations = relations(posts, ({ one }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
}));
The first problem I see is that when I run pnpm drizzle-kit generate:sqlite the foreign keys are not generated:
posts 3 columns 0 indexes 0 fks
users 2 columns 0 indexes 0 fks

[✓] Your SQL migration file ➜ drizzle/0000_silly_spitfire.sql 🚀
posts 3 columns 0 indexes 0 fks
users 2 columns 0 indexes 0 fks

[✓] Your SQL migration file ➜ drizzle/0000_silly_spitfire.sql 🚀
What am I missing?
1 replies