feat: add queries to search for users by username and for parent posts based on content
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { paginationOptsValidator } from 'convex/server';
|
||||
import { v } from 'convex/values';
|
||||
import { UserDto } from './../src/app/types/index';
|
||||
import {
|
||||
@@ -121,3 +122,15 @@ export const deleteUser = internalMutation({
|
||||
await ctx.db.delete(userRecord._id);
|
||||
},
|
||||
});
|
||||
|
||||
export const getUsersBySearchTerm = query({
|
||||
args: { term: v.string(), paginationOpts: paginationOptsValidator },
|
||||
handler: async (ctx, args) => {
|
||||
return await ctx.db
|
||||
.query('users')
|
||||
.withSearchIndex('search_by_username', q =>
|
||||
q.search('clerkUser.username', args.term)
|
||||
)
|
||||
.paginate(args.paginationOpts);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user