style: fix missing list styles in markdown content. feat: update post

This commit is contained in:
Stevan Freeborn
2023-09-11 20:02:20 -05:00
parent 3783bc34f0
commit 889cd08207
5 changed files with 98 additions and 30 deletions
+27 -1
View File
@@ -3,8 +3,9 @@ import { v } from 'convex/values';
import { mutation, query } from './_generated/server';
import { userQuery } from './users';
export const createPost = mutation({
export const createOrUpdatePost = mutation({
args: {
id: v.optional(v.id('posts')),
clerkUserId: v.string(),
content: v.array(v.string()),
parentPostId: v.optional(v.id('posts')),
@@ -25,6 +26,11 @@ export const createPost = mutation({
return 'CANNOT_POST_ON_BEHALF_OF_ANOTHER_USER';
}
if (args.id) {
await ctx.db.patch(args.id, { content: args.content });
return;
}
return await ctx.db.insert('posts', {
userId: user._id,
content: args.content,
@@ -43,3 +49,23 @@ export const getUsersPostById = query({
.paginate(args.paginationOpts);
},
});
export const deletePostById = mutation({
args: { id: v.id('posts') },
handler: async (ctx, args) => {
await ctx.db.delete(args.id);
},
});
export const getPostById = query({
args: { id: v.id('posts') },
handler: async (ctx, args) => {
const post = await ctx.db.get(args.id);
if (post === null) {
return 'POST_NOT_FOUND';
}
return post;
},
});