Stepan
Stepan7h ago

Updating one list item updates the entire list

This is a basic example of convex todo logic:
export const getAll = query({
handler: async (ctx) => {
return await ctx.db.query("todos").collect();
},
});

export const create = mutation({
args: {
text: v.string(),
},
handler: async (ctx, args) => {
const newTodoId = await ctx.db.insert("todos", {
text: args.text,
});
return await ctx.db.get(newTodoId);
},
});
export const getAll = query({
handler: async (ctx) => {
return await ctx.db.query("todos").collect();
},
});

export const create = mutation({
args: {
text: v.string(),
},
handler: async (ctx, args) => {
const newTodoId = await ctx.db.insert("todos", {
text: args.text,
});
return await ctx.db.get(newTodoId);
},
});
When the "create" mutation is called, convex sends the client a Transition containing the entire todo list, including those that haven't been updated.
{
"type": "Transition",
"startVersion": {
"querySet": 1,
"identity": 0,
"ts": "H9zkzpy2Zhg="
},
"endVersion": {
"querySet": 1,
"identity": 0,
"ts": "a4S3sMi3Zhg="
},
"modifications": [
{
"type": "QueryUpdated",
"queryId": 0,
"value": [
{
"_creationTime": 1758293489109.8918,
"_id": "j578a0636y8wcm4akgvzzv4wjd7qwjd9",
"completed": false,
"text": "data2"
},
{
"_creationTime": 1758294777103.2942,
"_id": "j575sseg4820aa551czakekzxs7qxkqd",
"completed": false,
"text": "data1"
}
],
"logLines": [],
"journal": null
}
],
"clientClockSkew": 1090,
"serverTs": 1758294777146437000
}
{
"type": "Transition",
"startVersion": {
"querySet": 1,
"identity": 0,
"ts": "H9zkzpy2Zhg="
},
"endVersion": {
"querySet": 1,
"identity": 0,
"ts": "a4S3sMi3Zhg="
},
"modifications": [
{
"type": "QueryUpdated",
"queryId": 0,
"value": [
{
"_creationTime": 1758293489109.8918,
"_id": "j578a0636y8wcm4akgvzzv4wjd7qwjd9",
"completed": false,
"text": "data2"
},
{
"_creationTime": 1758294777103.2942,
"_id": "j575sseg4820aa551czakekzxs7qxkqd",
"completed": false,
"text": "data1"
}
],
"logLines": [],
"journal": null
}
],
"clientClockSkew": 1090,
"serverTs": 1758294777146437000
}
I see this problem in the official example - https://github.com/get-convex/convex-demos/tree/main/pagination Is this normal and can it be avoided, and if so, what are the recommended practices?
1 Reply
Convex Bot
Convex Bot7h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!

Did you find this page helpful?