How to sync a document to user and then reallocate it to another user


I have worked out how to sync documents to specific users using the sync function e.g.
function(doc, oldDoc) {
if (doc.type == “todo”) {
if (doc.user) {
} else {
//Ignore. Not sure this is right
// but the documents end up on the correct device
} else {
//Ignore for now

So now I want to move the todo (on the server) from user1 to user2. i.e delete from user1 and create on user2. The only way I’ve managed it so far is to delete it from the shadow sync bucket and then recreate it with the amended user info.

Is there a better way to do this? Seems straight forward whilst there are no external references but once they exist its going to get complicated.


Channels assignation restarts from scratch each time you go through the sync function. So you would have to make sure the sync function does put the doc in a channel accessible by user2.