25 lines
602 B
TypeScript
25 lines
602 B
TypeScript
import { v } from "convex/values";
|
|
import { query, mutation } from "./_generated/server";
|
|
|
|
export const getAll = query({
|
|
handler: async (ctx) => {
|
|
return await ctx.db.query("funcionarios").collect();
|
|
},
|
|
});
|
|
|
|
export const create = mutation({
|
|
args: {
|
|
nome: v.string(),
|
|
matricula: v.string(),
|
|
simboloId: v.id("simbolos"),
|
|
},
|
|
handler: async (ctx, args) => {
|
|
const novoFuncionarioId = await ctx.db.insert("funcionarios", {
|
|
nome: args.nome,
|
|
matricula: args.matricula,
|
|
simboloId: args.simboloId,
|
|
});
|
|
return await ctx.db.get(novoFuncionarioId);
|
|
},
|
|
});
|