feat: enhance employee and symbol management with new features, improved UI components, and backend schema updates
This commit is contained in:
44
packages/backend/convex/roles.ts
Normal file
44
packages/backend/convex/roles.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { v } from "convex/values";
|
||||
import { query } from "./_generated/server";
|
||||
|
||||
/**
|
||||
* Listar todas as roles
|
||||
*/
|
||||
export const listar = query({
|
||||
args: {},
|
||||
returns: v.array(
|
||||
v.object({
|
||||
_id: v.id("roles"),
|
||||
nome: v.string(),
|
||||
descricao: v.string(),
|
||||
nivel: v.number(),
|
||||
setor: v.optional(v.string()),
|
||||
})
|
||||
),
|
||||
handler: async (ctx) => {
|
||||
return await ctx.db.query("roles").collect();
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Buscar role por ID
|
||||
*/
|
||||
export const buscarPorId = query({
|
||||
args: {
|
||||
roleId: v.id("roles"),
|
||||
},
|
||||
returns: v.union(
|
||||
v.object({
|
||||
_id: v.id("roles"),
|
||||
nome: v.string(),
|
||||
descricao: v.string(),
|
||||
nivel: v.number(),
|
||||
setor: v.optional(v.string()),
|
||||
}),
|
||||
v.null()
|
||||
),
|
||||
handler: async (ctx, args) => {
|
||||
return await ctx.db.get(args.roleId);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user