-
Notifications
You must be signed in to change notification settings - Fork 136
Update Mongoose to version 8.17.1 #725
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis PR updates Mongoose to v8, replaces deprecated query/deletion APIs (count → countDocuments, remove/delete → deleteOne), adds explicit Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
models/community.ts (1)
37-55: Avoid overridingDocument._idasstring
Documentalready defines_idasTypes.ObjectId. Overriding it tostringmasks the actual type and creates inconsistency with how MongoDB stores IDs natively. UseTypes.ObjectIdto reflect the actual stored type and align with the base interface.💡 Suggested type adjustment
-export interface ICommunity extends Document { - _id: string; +export interface ICommunity extends Document { + _id: Types.ObjectId; name: string; creator_id: string; group: string; order_channels: Types.DocumentArray<IOrderChannel>; fee: number; earnings: number; orders_to_redeem: number; dispute_channel: string; solvers: Types.DocumentArray<IUsernameId>; banned_users: Types.DocumentArray<IUsernameId>; public: boolean; currencies: Array<string>; created_at: Date; nostr_public_key: string; warning_messages_count: number; language: string; orders?: number; }
🤖 Fix all issues with AI agents
In `@models/order.ts`:
- Line 4: The IOrder interface currently types _id as string which mismatches
MongoDB ObjectId; update the _id declaration in the IOrder interface to use
mongoose.Types.ObjectId instead of string (or remove the override so the
Document-provided type is used), and if you need string IDs in API output add a
toJSON transform or convert _id.toString() at the serialization boundary; look
for the IOrder interface and its _id field in models/order.ts to apply this
change.
In `@package.json`:
- Line 28: package.json was bumped to "mongoose": "^8.17.1" so run npm install
to update lockfile and node_modules, then ensure all deprecated Mongoose APIs
were migrated: replace any usage of Model.count(...) with
Model.countDocuments(...), and replace Model.remove(...) with
Model.deleteOne(...) or Model.deleteMany(...) as appropriate; run the test suite
and fix any type or runtime errors caused by the upgrade (check call sites of
count/countDocuments and remove/deleteOne) before committing.
🧹 Nitpick comments (2)
bot/ordersActions.ts (1)
302-302: Inconsistent use of.exec()across queries.Adding
.exec()is valid but optional in Mongoose 8.x since queries are already thenables. However,Order.find(where)at line 340 and otherfindOnecalls in the codebase (e.g.,bot/start.ts:583) don't use.exec(). Consider either removing.exec()here for consistency, or adding it uniformly across all query calls.bot/modules/community/actions.ts (1)
63-65: Minor formatting inconsistency.Missing space after
ifkeyword on line 63. Per coding guidelines, Prettier formatting should be applied.🔧 Suggested fix
- if(community === null) + if (community === null)
|
@Luquitasjeffrey please don't merge until CI is green. |
PR for issue #655
Continuation of the PR #687
Summary by CodeRabbit
Dependencies
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.