feat: display user's posts on profile page
This commit is contained in:
+13
-1
@@ -1,5 +1,6 @@
|
||||
import { paginationOptsValidator } from 'convex/server';
|
||||
import { v } from 'convex/values';
|
||||
import { mutation } from './_generated/server';
|
||||
import { mutation, query } from './_generated/server';
|
||||
import { userQuery } from './users';
|
||||
|
||||
export const createPost = mutation({
|
||||
@@ -31,3 +32,14 @@ export const createPost = mutation({
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const getUsersPostById = query({
|
||||
args: { userId: v.id('users'), paginationOpts: paginationOptsValidator },
|
||||
handler: async (ctx, args) => {
|
||||
return await ctx.db
|
||||
.query('posts')
|
||||
.withIndex('by_user_id', q => q.eq('userId', args.userId))
|
||||
.order('desc')
|
||||
.paginate(args.paginationOpts);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user