Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Convex Queries #656

Closed
FleetAdmiralJakob opened this issue Nov 8, 2024 · 1 comment
Closed

Optimize Convex Queries #656

FleetAdmiralJakob opened this issue Nov 8, 2024 · 1 comment

Comments

@FleetAdmiralJakob
Copy link
Owner

Can be wrapped in Promise.all():

https://github.com/FleetAdmiralJakob/chat-io/blob/60b85ea4e13c2f1bf0497b0462ecd75bad2b23aa/convex/chats.ts#L13C1-L19

const messages = await chat.edge("messages").map(async (message) => ({
...message,
userId: undefined,
type: "message" as const,
from: await ctx.table("users").getX(message.userId),
readBy: await message.edge("readBy"),
sent: true,
}));
const requests = await chat.edge("clearRequests").map(async (request) => ({
...request,
userId: undefined,
status: undefined,
type: `${request.status}Request` as const,
from: await ctx.table("users").getX(request.userId),
sent: true,
}));

https://github.com/FleetAdmiralJakob/chat-io/blob/60b85ea4e13c2f1bf0497b0462ecd75bad2b23aa/convex/chats.ts#L113C1-L130C14

@FleetAdmiralJakob
Copy link
Owner Author

Fixed here: f3d0988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant