Skip to content

feat: add utility commands support (show dbs, show collections, getCollectionNames) - #4

Merged
d-bytebase merged 1 commit into
mainfrom
vk/65f1-mvp-of-gomongo-s
Jan 15, 2026
Merged

feat: add utility commands support (show dbs, show collections, getCollectionNames)#4
d-bytebase merged 1 commit into
mainfrom
vk/65f1-mvp-of-gomongo-s

Conversation

@h3n4l

@h3n4l h3n4l commented Jan 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Add support for show dbs / show databases - lists all databases using client.ListDatabaseNames()
  • Add support for show collections - lists collections in current database using db.ListCollectionNames()
  • Add support for db.getCollectionNames() - lists collection names (same as show collections)

This completes step 4 of the MVP implementation as specified in the design document.

Test plan

  • TestShowDatabases - verifies show dbs and show databases return database names
  • TestShowCollections - verifies show collections returns collection names
  • TestGetCollectionNames - verifies db.getCollectionNames() returns collection names
  • All existing tests continue to pass
  • Linter passes with 0 issues

🤖 Generated with Claude Code

…llectionNames)

Add support for MongoDB shell utility commands:
- `show dbs` / `show databases` - list all databases
- `show collections` - list collections in current database
- `db.getCollectionNames()` - list collection names in current database

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@d-bytebase
d-bytebase merged commit 85b7f39 into main Jan 15, 2026
7 checks passed
@d-bytebase
d-bytebase deleted the vk/65f1-mvp-of-gomongo-s branch January 15, 2026 02:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for MongoDB utility commands to list databases and collections, enabling show dbs, show databases, show collections, and db.getCollectionNames() operations. This completes step 4 of the MVP implementation.

Changes:

  • Added three new operation types (opShowDatabases, opShowCollections, opGetCollectionNames) to support utility commands
  • Implemented shell command visitor to handle show dbs/databases and show collections commands
  • Added execution functions that call MongoDB driver's ListDatabaseNames() and ListCollectionNames() APIs

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
translator.go Added new operation types and shell command visitor to parse show dbs/databases, show collections, and db.getCollectionNames() commands
executor.go Implemented execution functions for the new utility commands using MongoDB driver APIs
executor_test.go Added comprehensive test coverage for all three utility commands with database and collection setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread executor.go
Comment on lines +139 to +140
rows := make([]string, len(names))
copy(rows, names)

Copilot AI Jan 15, 2026

Copy link

Choose a reason for hiding this comment

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

The copy operation is unnecessary here. Since names is already a []string, you can directly assign it to rows instead of creating a new slice and copying. This simplifies the code: rows := names.

Copilot uses AI. Check for mistakes.
Comment thread executor.go
Comment on lines +155 to +156
rows := make([]string, len(names))
copy(rows, names)

Copilot AI Jan 15, 2026

Copy link

Choose a reason for hiding this comment

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

The copy operation is unnecessary here. Since names is already a []string, you can directly assign it to rows instead of creating a new slice and copying. This simplifies the code: rows := names.

Copilot uses AI. Check for mistakes.
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.

3 participants