Run a bunch of upsert tests on the direct collections (LocalCollection and
MongoConnection). Revealed a weirdness with MongoConnection.upsert(); if there
is no id from the selector or modifier, then mongo ends up generating one and we
don't return it.
Thus if two objects are EJSON.equals, their serialization strings will
be equal also.
(This should mean that reactive-dict could now allow objects to be
used as the key for `equal`).
Note this change does not affect livedata because livedata uses the
EJSON adjust functions to convert between JSON and EJSON (not
stringify).
Adds a couple options to EJSON.stringify:
* keyOrderSensitive: in parallel with EJSON.equals, outputs objects in
native key order (the old behavior).
* indent: pretty-prints the output.
The serialization code is based json2, which makes it easy to preserve
the indentation functionality provided by JSON.stringify. Only enough
code is included to serialize arrays and objects; serializing
primitive values such as strings is delegated to the native
JSON.stringify to reduce code and in case the native implementation is
more efficient.
Include underscore as an explicit dependency in package.js.
Document options to EJSON.equals and EJSON.stringify.
Get rid of numberAffectedCallback; instead, choose the right return value at
every place where we were using numberAffectedCallback and then pass through
bindEnvironmentForWrite. This cleans up a couple places where we were going
through numberAffectedCallback to wrap a result in an object, and then sometimes
getting the numberAffected out of that object and just returning that. Also
ensures that all callbacks for write get passed through Meteor.bindEnvironment
with the same onException function.
update(..., { upsert: true }) returns the number of affected docs, and
update(..., { upsert: true, _returnObject: true }) returns the whole object that
is used by upsert(). Also includes a rename of returnObject -> _returnObject.
Added a test for upsert return values. Factored out some more upsert test
helpers.
Could still use a test for update/remove return values inside a method stub.
Also:
* Fix some bugs: compareResults wasn't working so well; insertedId return values
weren't being passed through replaceTypes; a few places where options objects
weren't being treated as optional.
* Duplicate upsert tests for async upserts (with some changes to account for the
fact that updates and removes can only be by id). Maybe this can be cleaned up
to be less duplicate-y.
* Still need tests for async update/remove return values.
- Remove starter-browser-policy and replace it with
BrowserPolicy.enableContentSecurityPolicy(), which gives you the starter
policy and allows you to use the other BrowserPolicy functions to configure
it. This is motivated by the fact that the API isn't very intuitive without a
well-defined starting policy. ex: if the package starts off without a policy,
and then the user calls allowAllContentSameOrigin(), that will result in
turning off inline scripts, which is probably not what they wanted.
- AllContent functions do more of what you'd expect now;
i.e. BrowserPolicy.disallowAllContent() actually disallows all content,
instead of setting default-src to 'none', which will allow other types of
content that have previously had srcs set for them.
- Add some tests
* mongo_driver native upsert returns insertedId
* minimongo doesn't use query _id on upsert/replace
* minimongo supports insertedId option
* tests for all this
All tests pass now, but we've got the unfortunate situation that the
LocalCollection return values don't match the Meteor.Collection return values,
which is problematic because the minimongo tests use LocalCollection
directly. Hmm.