We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99c31ce commit fa4c980Copy full SHA for fa4c980
src/convex/schema.ts
@@ -7,7 +7,7 @@ export default defineSchema(
7
taskBody: v.string(),
8
isCompleted: v.boolean(),
9
user_id: v.string()
10
- })
+ }).index('by_user_id', ['user_id'])
11
},
12
{
13
schemaValidation: true
src/convex/tasks.ts
@@ -17,8 +17,10 @@ async function authorizeTaskAccess(
17
export const get = query({
18
args: { user_id: v.string() },
19
handler: async (ctx, args) => {
20
- const tasks = await ctx.db.query('tasks').collect();
21
- return tasks.filter((task) => task.user_id === args.user_id);
+ return await ctx.db
+ .query('tasks')
22
+ .withIndex('by_user_id', (q) => q.eq('user_id', args.user_id))
23
+ .collect();
24
}
25
});
26
0 commit comments