export const listCreatedShifts = query({
args: { },
handler: async (ctx, args) => {
const commentMap: Record<Id<"post">, any[]> = {}
for (let i = 0; i < posts.length; i++) {
const post = posts[i]
const comments = await ctx.db
.query("comments")
.withIndex("by_post", (q) => q.eq("post", post._id))
.collect()
commentMap[posts._id] = comments
}
return { posts, comments }
},
})
export const getPost = query({
args: { post: v.id("post") },
handler: async (ctx, args) => {
const post = await ctx.db.get(args.postId)
if (!post) {
throw new ConvexError("Post not found")
}
const comments = await ctx.db
.query("comments")
.withIndex("by_post", (q) => q.eq("post", post._id))
.collect()
export const listCreatedShifts = query({
args: { },
handler: async (ctx, args) => {
const commentMap: Record<Id<"post">, any[]> = {}
for (let i = 0; i < posts.length; i++) {
const post = posts[i]
const comments = await ctx.db
.query("comments")
.withIndex("by_post", (q) => q.eq("post", post._id))
.collect()
commentMap[posts._id] = comments
}
return { posts, comments }
},
})
export const getPost = query({
args: { post: v.id("post") },
handler: async (ctx, args) => {
const post = await ctx.db.get(args.postId)
if (!post) {
throw new ConvexError("Post not found")
}
const comments = await ctx.db
.query("comments")
.withIndex("by_post", (q) => q.eq("post", post._id))
.collect()