feat: Introduce structured table definitions in convex/tables for various entities and remove the todos example table.
This commit is contained in:
24
packages/backend/convex/tables/setores.ts
Normal file
24
packages/backend/convex/tables/setores.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { defineTable } from 'convex/server';
|
||||
import { v } from 'convex/values';
|
||||
|
||||
export const setoresTables = {
|
||||
// Setores da organização
|
||||
setores: defineTable({
|
||||
nome: v.string(),
|
||||
sigla: v.string(),
|
||||
criadoPor: v.id('usuarios'),
|
||||
createdAt: v.number()
|
||||
})
|
||||
.index('by_nome', ['nome'])
|
||||
.index('by_sigla', ['sigla']),
|
||||
|
||||
// Relação muitos-para-muitos entre funcionários e setores
|
||||
funcionarioSetores: defineTable({
|
||||
funcionarioId: v.id('funcionarios'),
|
||||
setorId: v.id('setores'),
|
||||
createdAt: v.number()
|
||||
})
|
||||
.index('by_funcionarioId', ['funcionarioId'])
|
||||
.index('by_setorId', ['setorId'])
|
||||
.index('by_funcionarioId_and_setorId', ['funcionarioId', 'setorId'])
|
||||
};
|
||||
Reference in New Issue
Block a user