diff options
Diffstat (limited to 'src/db/schema.ts')
| -rw-r--r-- | src/db/schema.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/db/schema.ts b/src/db/schema.ts new file mode 100644 index 0000000..322d78d --- /dev/null +++ b/src/db/schema.ts @@ -0,0 +1,43 @@ +; +import { relations } from 'drizzle-orm'; +import { integer, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'; +export const personas = sqliteTable('personas', { + id: integer('id').primaryKey({ autoIncrement: true }), + nombre: text('nombre').notNull(), + edad: integer('edad'), +}); + + + + +/* +export const categorias = sqliteTable('categorias', { + id: integer('id').primaryKey({ autoIncrement: true }), + nombre: text('nombre').unique().notNull(), + + +}); + + +export const productos = sqliteTable('productos', { + id: integer('id').primaryKey({ autoIncrement: true }), + nombre: text('nombre').unique().notNull(), + stock: integer('stock'), + precio: real('precio'), + categoriaId: integer('categoria_id').references(() => categorias.id), +}); + + + +export const categoriasRelations = relations(categorias, ({ many }) => ({ + productos: many(productos), +})); + +export const productosRelations = relations(productos, ({ one }) => ({ + pais: one(categorias, { + fields: [productos.categoriaId], + references: [categorias.id], + }), +})); + +*/
\ No newline at end of file |