unable to delete many
This is my action's handler
and the mutation
`
and apparently im getting this error.
complete error log below
const commentIds = duplicateComments.map((comment) => comment._id);
// Delete comments in batches of 20
for (let i = 0; i < commentIds.length; i += 20) {
const batch = commentIds.slice(i, i + 20);
if (batch.length > 0) {
try {
await ctx.runMutation(
api.functions.socialPostCommentsAdmin.deleteFromTableComments,
{
commentIds: batch,
},
);
} catch (error) {
console.error(`Error deleting comments ${batch}:`, error);
}
}
} const commentIds = duplicateComments.map((comment) => comment._id);
// Delete comments in batches of 20
for (let i = 0; i < commentIds.length; i += 20) {
const batch = commentIds.slice(i, i + 20);
if (batch.length > 0) {
try {
await ctx.runMutation(
api.functions.socialPostCommentsAdmin.deleteFromTableComments,
{
commentIds: batch,
},
);
} catch (error) {
console.error(`Error deleting comments ${batch}:`, error);
}
}
}and the mutation
export const deleteFromTableComments = mutation({
args: {
commentIds: v.array(v.id("socialPostComments")),
},
handler: async (ctx, args) => {
const { commentIds } = args;
const deleteCommentPromise = commentIds.map(async (id) => {
try {
await ctx.table("socialPostComments").getX(id).delete();
} catch (error) {
console.error(`Error deleting comments ${id}:`, error);
}
});
const deletedComments = await Promise.all(deleteCommentPromise);
return deletedComments;
},
});export const deleteFromTableComments = mutation({
args: {
commentIds: v.array(v.id("socialPostComments")),
},
handler: async (ctx, args) => {
const { commentIds } = args;
const deleteCommentPromise = commentIds.map(async (id) => {
try {
await ctx.table("socialPostComments").getX(id).delete();
} catch (error) {
console.error(`Error deleting comments ${id}:`, error);
}
});
const deletedComments = await Promise.all(deleteCommentPromise);
return deletedComments;
},
});and apparently im getting this error.
Uncaught Error: undefined is not a valid Convex value (present at path [0] in original object Uncaught Error: undefined is not a valid Convex value (present at path [0] in original object complete error log below
