-
Notifications
You must be signed in to change notification settings - Fork 1
feat(mongodb): implement milestone 1 read operations #52
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
Conversation
Add support for Milestone 1 read operations, utility commands, and aggregation: Collection methods: - countDocuments(filter?, options?) - estimatedDocumentCount(options?) - distinct(field, query?, options?) - aggregate(pipeline, options?) - getIndexes() Cursor modifiers: - count() Improvements: - Add 'new' keyword error handling with helpful message via NotifyErrorListeners - Reorganize test files by collection method (collection-*.js) - Remove redundant test files covered by new structure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Pull request overview
This PR implements Milestone 1 read operations for the MongoDB parser, adding support for advanced query methods (countDocuments, estimatedDocumentCount, distinct, aggregate, getIndexes) and the cursor count() modifier. The PR also reorganizes tests from inline test functions to separate example JavaScript files for better maintainability, and improves error handling for the 'new' keyword usage.
Changes:
- Added 6 new collection methods: countDocuments, estimatedDocumentCount, distinct, aggregate, getIndexes, and cursor count()
- Improved error handling for 'new' keyword with helpful error messages via NotifyErrorListeners
- Reorganized tests from inline Go test functions to separate .js example files by collection method
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| mongodb/MongoShellParser.g4 | Added grammar rules for new collection methods and consolidated 'new' keyword error handling |
| mongodb/MongoShellLexer.g4 | Added tokens for new collection methods and count cursor modifier |
| mongodb/mongoshell_parser.go | Generated parser code with new methods and updated rule indices |
| mongodb/mongoshellparser_visitor.go | Generated visitor interfaces for new method contexts |
| mongodb/mongoshellparser_listener.go | Generated listener interfaces for new method contexts |
| mongodb/mongoshellparser_base_visitor.go | Generated base visitor implementations |
| mongodb/mongoshellparser_base_listener.go | Generated base listener implementations |
| mongodb/parser_test.go | Removed inline tests, simplified to use file-based tests, updated error message assertion |
| mongodb/examples/collection-*.js | New example files testing each collection method comprehensively |
| mongodb/examples/find_operations.js | Removed (replaced by collection-find.js) |
| mongodb/examples/cursor_modifiers.js | Removed (integrated into collection-find.js) |
| mongodb/examples/collection_access.js | Removed (distributed across new example files) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| p.ExitRule() | ||
| return localctx | ||
| goto errorExit // Trick to prevent compiler error if the label is not used |
Copilot
AI
Jan 19, 2026
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.
This statement is unreachable.
| goto errorExit // Trick to prevent compiler error if the label is not used |
| } | ||
| p.ExitRule() | ||
| return localctx | ||
| goto errorExit // Trick to prevent compiler error if the label is not used |
Copilot
AI
Jan 19, 2026
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.
This statement is unreachable.
| } | ||
| p.ExitRule() | ||
| return localctx | ||
| goto errorExit // Trick to prevent compiler error if the label is not used |
Copilot
AI
Jan 19, 2026
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.
This statement is unreachable.
| goto errorExit // Trick to prevent compiler error if the label is not used |
Summary
Implement Milestone 1 read operations for the MongoDB parser as defined in the Gomongo milestone design:
countDocuments(filter?, options?)- count documents matching a filterestimatedDocumentCount(options?)- fast estimated count using metadatadistinct(field, query?, options?)- find distinct values for a fieldaggregate(pipeline, options?)- aggregation pipeline supportgetIndexes()- get all indexes on a collectioncursor.count()- cursor modifier to return countAlso includes:
newkeyword with helpful error message viaNotifyErrorListenerscollection-*.js) for better maintainabilityTest plan
make buildto regenerate parsermake testto verify all tests passnew ObjectId()produces helpful error message🤖 Generated with Claude Code