-
Notifications
You must be signed in to change notification settings - Fork 8
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
build: Upgrading dependencies for compatibility with Node 20 and general maintenance #926
Conversation
Drive-by comment: thanks for cleaning up this repository. Do you still need a review on this? Happy to review it. |
@pierreTklein For sure, that would be great! I think this just slipped through the cracks after the hackathon |
hackerDetails, | ||
logger.updateCallbackFactory(TAG, "hacker") | ||
); | ||
return logger.logUpdate(TAG, "hacker", Hacker.findOneAndUpdate(query, hackerDetails, { new: true })); |
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.
What's "new: true" here?
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.
By default, the newer Mongoose version returns the entity as it was before applying the update. Old Mongoose version had the opposite behaviour, so to replicate we must pass { new: true }
(docs).
tests/hacker.test.js
Outdated
JSON.stringify(hacker.toJSON()) | ||
chai.assert.deepStrictEqual( | ||
res.body.data, | ||
JSON.parse(JSON.stringify(hacker)), |
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.
Why are we parsing a stringified hacker? Could we instead just do hacker
? Not a rhetorical question. I am genuinely curious.
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.
So true, I think this was the most elegant solution I could find at that point (since hacker is a complex object of complex types like ObjectId and unfortunate fields like _id so it can't be directly compared to the response data). I hadn't realized the toJSON method of the Schemas were overridden which is why the method didn't work for me. Just pushed a fix
fbda26a
to
a378d76
Compare
List of changes:
new
and mongoose no longer accepting callbacks. We used to use thesequeryCallbackFactory
andupdateCallbackFactory
functions that actually ran every single query twice! I've migrated and fixed this behaviour so (technically) all queries should be twice as fast now 😂Type of change
Please delete options that are not relevant.
How has this been tested?
npm run test
is successful!Test Configuration:
Firmware version:
Hardware:
Toolchain:
SDK:
Questions for code reviewers?
None come to mind.
Checklist: