Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction data set correctly, but action is not done #58

Open
jetlej opened this issue Apr 13, 2016 · 4 comments
Open

Transaction data set correctly, but action is not done #58

jetlej opened this issue Apr 13, 2016 · 4 comments

Comments

@jetlej
Copy link

jetlej commented Apr 13, 2016

I'm getting what looks to be correct messages in console, but the action itself is not being done in the first place.

VM1659 babrahams_transactions.js?hash=8ed90df…:110 Started "update article" with transaction_id: 3zwh9dmfJyfhZ8XWB (auto started)
2VM1659 babrahams_transactions.js?hash=8ed90df…:110 Pushed update command to stack: 3zwh9dmfJyfhZ8XWB
VM1659 babrahams_transactions.js?hash=8ed90df…:110 Auto committed: 3zwh9dmfJyfhZ8XWB
VM1659 babrahams_transactions.js?hash=8ed90df…:110 Beginning commit with transaction_id: 3zwh9dmfJyfhZ8XWB

Relevant line of code: return Articles.update(query, { $set: data }, {tx: true});

@JackAdams
Copy link
Owner

JackAdams commented Apr 15, 2016

Just check that the query object has an _id value set (the transactions package ignores everything else in the object). That query isn't treated like a true mongo selector (at all). See 1. here.

@jetlej
Copy link
Author

jetlej commented May 3, 2016

The query object definitely has an _id value set, and it's the only value set in that object.

Here's some more sample code (defined as Meteor methods):

approveArticle: function(id, owner) {
    Meteor.call('updateArticle', id, {
        status: STATUS_APPROVED,
        owner: null,
        lastChanged: new Date()
    });
},

updateArticle: function(id, data) {
    return Articles.update({_id: id}, { $set: data }, {tx: true});
}

Any other suggestions?

@jetlej
Copy link
Author

jetlej commented Jun 16, 2016

Bump

@JackAdams
Copy link
Owner

Hmmm... not sure what to suggest here. That code looks fine to me. Note: the return value from the method shown above will not be the return value from the mongo update command, it will just be true if the transaction has been completed as expected.

If there's a minimal repro I could look at I could figure out what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants