feat: sync convex companies and dashboard metrics
This commit is contained in:
parent
4f52114b48
commit
7a3eca9361
10 changed files with 356 additions and 19 deletions
|
|
@ -85,3 +85,24 @@ export const ensureProvisioned = mutation({
|
|||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const removeBySlug = mutation({
|
||||
args: {
|
||||
tenantId: v.string(),
|
||||
slug: v.string(),
|
||||
},
|
||||
handler: async (ctx, { tenantId, slug }) => {
|
||||
const normalizedSlug = normalizeSlug(slug) ?? slug
|
||||
const existing = await ctx.db
|
||||
.query("companies")
|
||||
.withIndex("by_tenant_slug", (q) => q.eq("tenantId", tenantId).eq("slug", normalizedSlug))
|
||||
.unique()
|
||||
|
||||
if (!existing) {
|
||||
return { removed: false }
|
||||
}
|
||||
|
||||
await ctx.db.delete(existing._id)
|
||||
return { removed: true }
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue