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

Remove usage of deprecated database.writeOptions. #51

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

JSAssassin
Copy link
Contributor

@JSAssassin JSAssassin commented Aug 28, 2023

Addresses #19

update.$setOnInsert = {
'meta.created': now,
'acquisition.acquirerId': acquirerId
};
} else {
dbOptions = database.writeOptions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if the above works or not, i.e., if it behaves the same whether we bring in all of the options manually and layer upsert on top or if we can just pass upsert and it will auto-layer it onto the existing options. I know at some point this didn't work, but I'm hopeful it does now. If someone could hack into the code (down deep in the mongodb driver layer) and print out what it does to confirm that it's the same, that would be ideal.

Copy link
Contributor Author

@JSAssassin JSAssassin Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlongley Here's what the options look like when it gets to mongodb:
https://gist.github.com/JSAssassin/09b25aa872baadcaa677438f7a88ae5c#file-finaloptions_mongodb_updateone-md

Looks the same except forceServerObjectId is missing from the one where we only pass upsert.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JSAssassin,

Thanks, being able to see the differences is excellent. I was mostly concerned about writeConcern being the same -- and other than some WriteConcern wrapper being used in some cases, it looks the same, so I presume we're good there. We don't do anything special with _id ... so I don't think we need to worry about forceServerObjectId either way. This looks good, thank you!

@@ -93,7 +93,7 @@ export async function bulkInsert({restrictions} = {}) {
const meta = {created: now, updated: now};
let records = restrictions.map(restriction => ({restriction, meta}));
// allow unordered writes
const writeOptions = {...database.writeOptions, ordered: false};
const writeOptions = {ordered: false};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from drop-node-16 to main August 29, 2023 18:34
@codecov-commenter
Copy link

Codecov Report

Merging #51 (f96dac1) into main (a67d68d) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   90.44%   90.43%   -0.02%     
==========================================
  Files           6        6              
  Lines        1382     1380       -2     
==========================================
- Hits         1250     1248       -2     
  Misses        132      132              
Files Changed Coverage Δ
lib/resources.js 89.20% <100.00%> (-0.05%) ⬇️
lib/restrictions.js 93.23% <100.00%> (ø)

@dlongley dlongley merged commit 0d9ff61 into main Aug 30, 2023
4 checks passed
@dlongley dlongley deleted the remove-database-writeOptions branch August 30, 2023 00:24
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

Successfully merging this pull request may close these issues.

4 participants