feat(*): first mvp
This commit is contained in:
45
frontend/src/lib/convex/pendingGenerations.ts
Normal file
45
frontend/src/lib/convex/pendingGenerations.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { v } from 'convex/values';
|
||||
import { mutation, query } from './_generated/server';
|
||||
|
||||
export const list = query({
|
||||
args: {},
|
||||
returns: v.array(
|
||||
v.object({
|
||||
_id: v.id('pendingGenerations'),
|
||||
_creationTime: v.number(),
|
||||
userId: v.id('users'),
|
||||
chatId: v.id('chats'),
|
||||
userMessage: v.string(),
|
||||
createdAt: v.number()
|
||||
})
|
||||
),
|
||||
handler: async (ctx) => {
|
||||
return await ctx.db.query('pendingGenerations').collect();
|
||||
}
|
||||
});
|
||||
|
||||
export const create = mutation({
|
||||
args: {
|
||||
userId: v.id('users'),
|
||||
chatId: v.id('chats'),
|
||||
userMessage: v.string()
|
||||
},
|
||||
returns: v.id('pendingGenerations'),
|
||||
handler: async (ctx, args) => {
|
||||
return await ctx.db.insert('pendingGenerations', {
|
||||
userId: args.userId,
|
||||
chatId: args.chatId,
|
||||
userMessage: args.userMessage,
|
||||
createdAt: Date.now()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const remove = mutation({
|
||||
args: { id: v.id('pendingGenerations') },
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.delete(args.id);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user