Skip to content

Commit

Permalink
Adding support for arrayFilters in updates (#4248)
Browse files Browse the repository at this point in the history
* Adding support for arrayFilters in updates

This PR is for the feature request [#4247](#4247).

This PR adds support for arrayFilters by passing the arrayFilters parameter to the Realm serverless function.

Additional testing was added to cover the case of an update with arrayFilters.

* Fix linting errors

* Reverted change in package.json that caused tests to fail

* Fixing the test to insert a single item

* Update CHANGELOG.md

* Update CHANGELOG.md

* Trying to get those tests to pass

* Update remote-mongodb-service.test.ts

Co-authored-by: Kræn Hansen <[email protected]>
Co-authored-by: Kræn Hansen <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2022
1 parent e0ac3b0 commit 03621d2
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Please note the following API changes from the `10.12.0-beta.1` release of Flexi
* Support arithmetic operations (+, -, *, /) in queries. Operands can be properties and/or constants of numeric types (`int`, `float`, `double` or `Decimal128`). You can now say something like `(age + 5) * 2 > child.age`.
* `Realm.writeCopyTo()` now supports creating snapshots of synced Realms, thus allowing apps to be shipped with partially-populated synced databases. ([#3782](https://github.com/realm/realm-js/issues/3782)
* Added beta support for flexible sync ([#4220](https://github.com/realm/realm-js/pull/4220)).
* Adding support for passing the `arrayFilters` parameter when updating documents using the remote MongoDB client. ([#4248](https://github.com/realm/realm-js/pull/4248))

### Fixed
* Opening a Realm with a schema that has an orphaned embedded object type performed an extra empty write transaction. ([realm/realm-core#5115](https://github.com/realm/realm-core/pull/5115), since v10.5.0)
Expand Down
2 changes: 2 additions & 0 deletions docs/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ class MongoDBCollection {
* @param {object} [options] Additional options to apply.
* @param {boolean} [options.upsert=false] if true, indicates that MongoDB should insert a new document that matches the
* query filter when the query does not match any existing documents in the collection.
* @param {object[]} [options.arrayFilters=false] if provided, indicates the arrayFilters to use to update an embedded array.
* @returns {Promise<Realm.MongoDBCollection~UpdateResult>}
*/
updateOne(filter, update, options) {}
Expand All @@ -1291,6 +1292,7 @@ class MongoDBCollection {
* @param {object} [options] Additional options to apply.
* @param {boolean} [options.upsert=false] if true, indicates that MongoDB should insert a new document that matches the
* query filter when the query does not match any existing documents in the collection.
* @param {object[]} [options.arrayFilters=false] if provided, indicates the arrayFilters to use to update an embedded array.
* @returns {Promise<Realm.MongoDBCollection~UpdateResult>}
*/
updateMany(filter, update, options) {}
Expand Down
2 changes: 2 additions & 0 deletions lib/mongo-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class MongoDBCollection {
query: filter,
update,
upsert: options.upsert,
arrayFilters: options.arrayFilters,
});
}

Expand All @@ -194,6 +195,7 @@ class MongoDBCollection {
query: filter,
update,
upsert: options.upsert,
arrayFilters: options.arrayFilters,
});
}

Expand Down
227 changes: 167 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 03621d2

Please sign in to comment.