Yvens
Yvens
CCConvex Community
Created by Yvens on 8/29/2024 in #support-community
[Convex ents] Getting Multiple docs using compound index in the most efficient way
Hello, How would you get a list of document using ents ?
photos: defineEnt({
clientId: v.id("organization_clients"),
organizationId: v.id("organizations"),
storageId: v.id("_storage"),
is_published_to_instagram: v.boolean(),
})
.field("instagram_id", v.optional(v.string()), { index: true })
.index("by_organization_instagram_id", ["organizationId", "instagram_id"])
.index("by_organization_client", ["organizationId", "clientId"])
photos: defineEnt({
clientId: v.id("organization_clients"),
organizationId: v.id("organizations"),
storageId: v.id("_storage"),
is_published_to_instagram: v.boolean(),
})
.field("instagram_id", v.optional(v.string()), { index: true })
.index("by_organization_instagram_id", ["organizationId", "instagram_id"])
.index("by_organization_client", ["organizationId", "clientId"])
Since this bellow, let you only read a single document with a compound index
const task = await ctx.table("users").get("nameAndRank", "Steve", 10);
const task = await ctx.table("users").get("nameAndRank", "Steve", 10);
1 replies
CCConvex Community
Created by Yvens on 6/12/2024 in #support-community
Mock Service Worker implementation
Hello guys, I'm giving a go at MSW, and I'm not sure about the implementation. The way I do it feel strange to me does anyone could give it a look and let me know if it makes sense ? Link of the gist: https://gist.github.com/Yvens16/bdd3cabd79bdc73791f7342f280a955d
4 replies
CCConvex Community
Created by Yvens on 5/1/2024 in #support-community
Paginate many to many edge (ents)
Hello, I don't get how to paginate a many to many query on convex-ents:
const result = username === ""
? await ctx.table("organizations").getX(organizationId).edge("users")
: await ctx
.table("users")
.search("search_username", (q) => q.search("username", username).eq("organizationId", organizationId))
.paginate(paginationOpts);
return result;
const result = username === ""
? await ctx.table("organizations").getX(organizationId).edge("users")
: await ctx
.table("users")
.search("search_username", (q) => q.search("username", username).eq("organizationId", organizationId))
.paginate(paginationOpts);
return result;
` My problem is on this line :
await ctx.table("organizations").getX(organizationId).edge("users")
await ctx.table("organizations").getX(organizationId).edge("users")
``
8 replies
CCConvex Community
Created by Yvens on 4/29/2024 in #support-community
Optional one to many relationship (convex-ents)
Hello, Is there a way to make an optional one to many relationship using egdes ? I would like to affect users to a group or no group.
users: defineEnt({})
.edge("user_group", { field: "groupId" }),
user_groups: defineEnt({})
.edges("users", { ref: "groupId" })
users: defineEnt({})
.edge("user_group", { field: "groupId" }),
user_groups: defineEnt({})
.edges("users", { ref: "groupId" })
`
9 replies
CCConvex Community
Created by Yvens on 4/24/2024 in #support-community
Convex-test/ents
Is there a way to use ctx.table in a test ?
await t.run(async (ctx) => {
// roles created
ctx.table("users").insert({ firstname, roles: [roleId1, roleId2] })
});
await t.run(async (ctx) => {
// roles created
ctx.table("users").insert({ firstname, roles: [roleId1, roleId2] })
});
Or should I insert data in the "users_to_roles" table created by ents ?
const t = convexTest(schema);
await t.run(async (ctx) => {
// roles created
// users created
ctx.db.insert("users_to_roles", { userId, roleId })
});
const t = convexTest(schema);
await t.run(async (ctx) => {
// roles created
// users created
ctx.db.insert("users_to_roles", { userId, roleId })
});
I don't get how to re-create the edge in my db setup. Thank you
42 replies
CCConvex Community
Created by Yvens on 4/5/2024 in #support-community
Problem testing convex function with convex-test.
No description
18 replies