25 lines
680 B
TypeScript
25 lines
680 B
TypeScript
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'])
|
|
};
|