amppA
Convex Community2y ago
49 replies
ampp

ent filtering

trying to do this but it never returns a result unless args.name is null, tried several variations. Looked through the saas starter for examples like this. the goal is to find any channel names so you cant enter a duplicate name within the same team.
const channel = await ctx.table("teams")
.get(args.teamId)
.edge("chatChannels")
.filter((q) => q.gt(q.field("name"), args.name));
---
chatChannels: defineEnt({
name: v.string(),
})
.index("name", ["name"]) <- added this too
.edge("team")
.edges("chatMessages", { ref: true }),
---
orginal code:
const channel = await ctx.db
.query("chatChannels")
.filter((q) => q.eq(q.field("name"), name))
.filter((q) => q.eq(q.field("teams"), teamId))
.first();
Was this page helpful?