I have a couple of related Meteor collections – Boards and Items. Items belong to Boards, so they have fields named board, which are references to the _ids of board records in Mongo.
I'm trying to implement a copyBoard method, which:
1. Inserts a copy of a board record
2. Inserts copies of all of the items associated with that board and sets their board fields to the new board record created in step 1.
The problem I'm running into is that the client side stub gives me a new board record that has a temporary _id. I use that to set the board field of the new item records created in duplicateRecords. When Meteor syncs it back to the server, it changes that board's _id, but the new item records are stuck with the client-side temporary _id in their board fields, which now points to nothing.
I was thinking of not inserting the items until the new board has synced to the server, but I'm not sure how to do that without publishing a separate "new board" collection. Seems there's probably a better approach. Is there?