-
Notifications
You must be signed in to change notification settings - Fork 237
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
Atomic upsertWithWhere #563
Conversation
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@mrbatista Thank you for the PR. Could you add some tests for the changes? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We just switch the contribution method from CLA to DCO, making your contribution easier in the future. Please sign the commits with DCO by amending your commit messages with
Please refer to this docs page for details. Thanks! For more questions, please join our Slack workspace - #loopback-contributors. |
@mrbatista @fabien I don't understand why you would want to use a transactional operation? Maybe I'm missing something. Atomic upsert and document return is achieved with findAndModify operation with the "new" and "update" flags. transactional seems overkill. |
@mrbatista Atomic I fully understand but why transactional? I too need an atomic version which is implemented by MongoDB native findAndModify with the appropriate parameters. Your ticket mentions transactional, which is not the same as an atomic opetation. Would it not be sufficient to implement findAndModify (with new and upsert parameters) in the connector to parse any of the DOA's upsertWithWhere operations? |
@jamesjjk I changed the title to respect the implementation of this PR. |
@mrbatista Understood, are you updating the respective connector? Which connector are you using if I may ask? |
I'm currently using my fork which implements atomic upsertWithWhere. |
09d48b3
to
d69266e
Compare
06c0958
to
be18dae
Compare
See loopbackio/loopback-connector-mongodb#563 Signed-off-by: Matteo Padovano <[email protected]>
@agnes512 I have update the PR and first comment. Please review. To have green tests need to merge this PR loopbackio/loopback-datasource-juggler#1864 |
Thanks @mrbatista , I merged and published the juggler test, but it fails due to
juggler-v3 complains the same problem. Could you take a look? |
cc @mrbatista any update about the test? |
@jannyHou On my local environment only the juggler 3.x fail. |
Introduce the new property atomicUpsertWithWhere for connector that implement specific method. See loopbackio/loopback-connector-mongodb#563 for mongodb implementation. Signed-off-by: Matteo Padovano <[email protected]>
@mrbatista Thanks, I see created PR loopbackio/loopback-datasource-juggler#1871 to back port it. |
Introduce the new property atomicUpsertWithWhere for connector that implement specific method. See loopbackio/loopback-connector-mongodb#563 for mongodb implementation. Signed-off-by: Matteo Padovano <[email protected]>
@jannyHou Any update on this PR? |
Hi @mrbatista sorry for late update, I am making time to address the feedback in loopbackio/loopback-datasource-juggler#1871, after that, this PR should be good to land. |
Introduce the new property atomicUpsertWithWhere for connector that implement specific method. See loopbackio/loopback-connector-mongodb#563 for mongodb implementation. Signed-off-by: Matteo Padovano <[email protected]>
Introduce the new property atomicUpsertWithWhere for connector that implement specific method. See loopbackio/loopback-connector-mongodb#563 for mongodb implementation. Signed-off-by: Matteo Padovano <[email protected]>
Introduce the new property atomicUpsertWithWhere for connector that implement specific method. See loopbackio/loopback-connector-mongodb#563 for mongodb implementation. Signed-off-by: Matteo Padovano <[email protected]> Co-authored-by: Matteo Padovano <[email protected]>
@slnode test please |
I wanted to re-run Travis CI build but it looks like the old Travis at https://travis-ci.org does not allow that (or I don't have permissions to do so). I think we will need to force-push to the feature branch to trigger a new build, can you @jannyHou PTAL? We need a new run to pick the recently released versions of juggler v3 and v4 that should fix the failure of the test it fails the upsertWithWhere operation when multiple instances are retrieved based on the filter criteria |
@bajtos thank you for looking into the error, triggered a test. |
It failed because I didn't release the change in juggler v3. Just released 3.36.1, let me rerun it. Great it passed. |
8a1b37e
to
16d31cb
Compare
@jannyHou green CI 🎉🥳 |
Signed-off-by: = <[email protected]>
16d31cb
to
9dcd1db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Cheers!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏻
Signed-off-by: = <[email protected]>
* atomic upsertWithWhere (loopbackio#563) (Matteo Padovano)
Use each to itterate through restuls rather than toArray to aviod issues with large datasets [fixes loopbackio#129] chore(release): v7.0.0-alpha.1 * ci: update Node.js test matrix (Rifa Achrinza) * chore: update Node.js engine matrix (Rifa Achrinza) * feat: upgrade mongodb driver to version 4.x (Antonio Ramón Sánchez Morales) * chore: lock file maintenance (renovate[bot]) * chore: update supercharge/mongodb-github-action action to v1.8.0 (renovate[bot]) * chore: update dependency eslint to ^8.23.0 (renovate[bot]) * chore: update commitlint monorepo to v17 (renovate[bot]) * chore: update dependency eslint to ^8.19.0 (renovate[bot]) * chore: update github/codeql-action action to v2 (renovate[bot]) * chore: update dependency mocha to ^9.2.2 (renovate[bot]) * chore: update dependency loopback-datasource-juggler to ^4.27.1 (renovate[bot]) * chore: update dependency eslint to ^8.18.0 (renovate[bot]) * chore: update dependency strong-globalize to ^6.0.5 (renovate[bot]) * chore: update supercharge/mongodb-github-action action to v1.7.0 (renovate[bot]) * chore: update actions/setup-node action to v3 (renovate[bot]) * chore: update actions/checkout action to v3 (renovate[bot]) * chore: update dependency semver to ^7.3.7 (renovate[bot]) * chore: update dependency should to ^13.2.3 (renovate[bot]) * chore: update dependency debug to ^4.3.4 (renovate[bot]) * chore: update dependency loopback-connector to ^5.0.1 (renovate[bot]) * chore: update dependency bson to ^1.1.6 (renovate[bot]) * chore: update dependency bluebird to ^3.7.2 (renovate[bot]) * chore: update dependency async to ^3.2.4 (renovate[bot]) * ci: add renovate config (Rifa Achrinza) * fix(*): run autoupdate in serial to avoid conflicts (Simon Stone) * fix: optional chaining (preussmann) * chore: update v6 EOL (Rifa Achrinza) * ci: test against Node.js v18 (Rifa Achrinza) Signed-off-by: Rifa Achrinza <[email protected]> ci: update Node.js test matrix Signed-off-by: Rifa Achrinza <[email protected]> chore: update Node.js engine matrix BREAKING CHANGE: This drops explicit, documented support for Node.js v10, v11, v12, v13, v15, v17 Signed-off-by: Rifa Achrinza <[email protected]> feat: upgrade mongodb driver to version 4.x Signed-off-by: Antonio Ramón Sánchez Morales <[email protected]> chore: lock file maintenance Signed-off-by: Renovate Bot <[email protected]> chore: update supercharge/mongodb-github-action action to v1.8.0 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency eslint to ^8.23.0 Signed-off-by: Renovate Bot <[email protected]> chore: update commitlint monorepo to v17 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency eslint to ^8.19.0 Signed-off-by: Renovate Bot <[email protected]> chore: update github/codeql-action action to v2 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency mocha to ^9.2.2 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency loopback-datasource-juggler to ^4.27.1 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency eslint to ^8.18.0 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency strong-globalize to ^6.0.5 Signed-off-by: Renovate Bot <[email protected]> chore: update supercharge/mongodb-github-action action to v1.7.0 Signed-off-by: Renovate Bot <[email protected]> chore: update actions/setup-node action to v3 Signed-off-by: Renovate Bot <[email protected]> chore: update actions/checkout action to v3 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency semver to ^7.3.7 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency should to ^13.2.3 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency debug to ^4.3.4 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency loopback-connector to ^5.0.1 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency bson to ^1.1.6 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency bluebird to ^3.7.2 Signed-off-by: Renovate Bot <[email protected]> chore: update dependency async to ^3.2.4 Signed-off-by: Renovate Bot <[email protected]> ci: add renovate config see: loopbackio/cicd#15 Signed-off-by: Rifa Achrinza <[email protected]> fix(*): run autoupdate in serial to avoid conflicts Signed-off-by: Simon Stone <[email protected]> fix: optional chaining fixed error if this._models[modelName] is an empty object Signed-off-by: minp <[email protected]> chore: update v6 EOL Signed-off-by: Rifa Achrinza <[email protected]> ci: test against Node.js v18 see: loopbackio/cicd#27 Signed-off-by: Rifa Achrinza <[email protected]> 6.2.0 * docs: add SECURITY.md (Diana Lau) * chore: tls README example (d-bo) * docs: update coc (Diana Lau) * docs: add code of conduct (Diana Lau) * chore: update v6 EOL (Rifa Achrinza) * ci: fix typo (Rifa Achrinza) * chore: update deps (Rifa Achrinza) * feat: add tls options as of mongo 3.7 (d-bo) * ci: update Node.js version (Rifa Achrinza) * ci: pin NPM version (Rifa Achrinza) * chore: add @achrinza and update CODEOWNERS (Diana Lau) * fix: isObjectIDProperty array param check (Rifa Achrinza) * fix: handle url default db name (Rifa Achrinza) * ci: restrict GITHUB_TOKEN permissions (Rifa Achrinza) docs: add SECURITY.md Signed-off-by: Diana Lau <[email protected]> chore: tls README example Signed-off-by: d-bo <[email protected]> docs: update coc Signed-off-by: Diana Lau <[email protected]> docs: add code of conduct Signed-off-by: Diana Lau <[email protected]> chore: update v6 EOL Coninuation of loopbackio#652 Signed-off-by: Rifa Achrinza <[email protected]> ci: fix typo Signed-off-by: Rifa Achrinza <[email protected]> chore: update deps Signed-off-by: Rifa Achrinza <[email protected]> feat: add tls options as of mongo 3.7 Signed-off-by: d-bo <[email protected]> ci: update Node.js version see: loopbackio/cicd#2 see: loopbackio/cicd#4 Signed-off-by: Rifa Achrinza <[email protected]> ci: pin NPM version see: loopbackio/cicd#6 Signed-off-by: Rifa Achrinza <[email protected]> chore: add @achrinza and update CODEOWNERS Signed-off-by: Diana Lau <[email protected]> fix: isObjectIDProperty array param check fixes loopbackio#645 Signed-off-by: Rifa Achrinza <[email protected]> fix: handle url default db name Co-authored-by: Nico Flaig <[email protected]> Signed-off-by: Rifa Achrinza <[email protected]> ci: restrict GITHUB_TOKEN permissions Signed-off-by: Rifa Achrinza <[email protected]> 6.1.0 * ci: misc updates (Rifa Achrinza) * feat: add transaction support (Sergey Nosenko) * ci: align gh actions workflow with 5.x (Rifa Achrinza) * chore: move repo to loopbackio org (Diana Lau) ci: misc updates - Enable Node.js v16 testing - Update supercharge/mongodb-github-action to v1.6.0 - Enable amd64/8 testing - Re-enable coverage reporting - General CI sync with other pipelines. Signed-off-by: Rifa Achrinza <[email protected]> feat: add transaction support Signed-off by: Sergey Nosenko <[email protected]> Signed-off-by: Rifa Achrinza <[email protected]> ci: align gh actions workflow with 5.x see loopbackio#634 Signed-off-by: Rifa Achrinza <[email protected]> chore: move repo to loopbackio org Signed-off-by: Diana Lau <[email protected]> 6.0.1 * fix: allows fields filter with custom field name (louis.nguyen) * README: update notes about 6.0 (Miroslav Bajtoš) fix: allows fields filter with custom field name Signed-off-by: louis.nguyen <[email protected]> README: update notes about 6.0 Remove the message "6.0 is in development", update LTS table with the correct date of publishing v6.0.0 Signed-off-by: Miroslav Bajtoš <[email protected]> 6.0.0 * coerce values of array defined as ObjectID type (=) * Update mongodb to ^3.6.4 (wolrajhti) * ci: convert from Travis to Github action ci (Agnes Lin) * README: mention our work on 6.0 (Miroslav Bajtoš) * [SEMVER-MAJOR] Drop support for LoopBack 3.x (Yaapa Hage) coerce values of array defined as ObjectID type Signed-off-by: = <[email protected]> Update mongodb to ^3.6.4 Signed-off-by: wolrajhti <[email protected]> ci: convert from Travis to Github action ci Signed-off-by: Agnes Lin <[email protected]> [SEMVER-MAJOR] Drop support for LoopBack 3.x Signed-off-by: Yaapa Hage <[email protected]> README: mention our work on 6.0 Signed-off-by: Miroslav Bajtoš <[email protected]> 5.5.0 * atomic upsertWithWhere (loopbackio#563) (Matteo Padovano) atomic upsertWithWhere (loopbackio#563) Signed-off-by: = <[email protected]>
Implement atomic upsertWithWhere method.
The out-of-the-box implementation catch error if multiple instances are founds.
With atomic implementation one test present in the juggler datasource will be disabled.
I added a new option to specify if connector has an atomic implementation. See loopbackio/loopback-datasource-juggler#1864.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machine