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

Rethink namespacing of tx options #86

Open
mattmccutchen opened this issue Feb 11, 2017 · 3 comments
Open

Rethink namespacing of tx options #86

mattmccutchen opened this issue Feb 11, 2017 · 3 comments

Comments

@mattmccutchen
Copy link
Collaborator

The readme says:

Note: the options can also be passed as follows: Players.insert({name: "New player"}, {tx: {instant: true}});. This can be used to avoid potential namespace collisions with other packages that use the same options hash, such as aldeed:collection2. As soon as an options hash is passed as the value for tx (instead of true), this package won't consider any other options except those in the hash.

What are the relevant scenarios here? If we add support for the standard multi (#80) and upsert (#84) options, it seems natural to me to pass them at the top level even if a tx object is used. In particular, a call to collection.upsert(sel, mod, {tx: {...}}) will get automatically turned into collection.update(sel, mod, {upsert: true, tx: {...}}), and it would be confusing if that didn't do an upsert.

@JackAdams
Copy link
Owner

JackAdams commented Feb 11, 2017 via email

@mattmccutchen
Copy link
Collaborator Author

mattmccutchen commented Feb 12, 2017

That would make sense, but it doesn't seem to be what the code does. It sets opt = opt.tx here and doesn't save the original opt anywhere. If you don't mind breaking any apps that might be relying on the current behavior, we can switch to the intended behavior; it just means passing two arguments through the code, opt and txOpt (where either txOpt == opt or txOpt == opt.tx), and making sure we're looking at the proper one in each place. But are name collisions enough of a risk to justify keeping this feature at all if we're breaking the old behavior anyway and no one has complained about the fact that the old behavior didn't actually avoid name collisions?

@JackAdams
Copy link
Owner

JackAdams commented Feb 12, 2017 via email

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