Add MongoDB support as storage back-end#27
Conversation
Reviewer's GuideIntroduces MongoDB as a first-class storage backend by adding a MongoDBStore implementation conforming to the existing Store interface, wiring it through the factory and configuration options, and supporting it with documentation, examples, dependency updates, and integration tests. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @ronanzindev - I've reviewed your changes - here's some feedback:
- Consider extending StorageConfig with dedicated fields for MongoDB database and collection instead of overloading TableName with a "db.collection" string.
- Fix the typo in the API reference docs—
WithMongoDBStorateshould beWithMongoDBStorage. - Align the env var in your MongoDB store tests (
MONGO_URI) with the GOVISUAL_MONGO_URI name used in examples/configuration to avoid confusion and skipped tests.
Here's what I looked at during the review
- 🟡 General issues: 6 issues found
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| capacity = 100 | ||
| } | ||
|
|
||
| ctx := context.Background() |
There was a problem hiding this comment.
suggestion: A background context is used for all DB operations, which may hinder graceful shutdown.
Requests started with context.Background can’t be canceled or timed out. To enable graceful shutdown, accept a context parameter or use a cancellable context.
| mongoMetaData := strings.Split(config.TableName, ".") | ||
| if len(mongoMetaData) < 2 { |
There was a problem hiding this comment.
issue: Splitting TableName on '.' assumes no '.' in database or collection names.
Use a more robust parsing approach for database and collection names (instead of splitting on '.') or clearly document this limitation.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
…d, and update module versions in go.sum.
This PR adds support for using MongoDB as a storage back-end in GoVisual.
Based on #6
Problem solved:
GoVisual currenty supports only PostgreSQL,Redis and SQLite as storage back-ends. However, there was no option for document-base, high perfomace for write/read operations, schema flexibility for request/response structures and native JSON support for HTTP, like MongoDB
Summary of changes:
MongoDBStoragewith same interface and begavior as the existing storages back-end.Summary by Sourcery
Add MongoDB as a new back-end for GoVisual, providing a fast schema flexibility persistent storage option.
New Features:
Enhancements:
Summary by Sourcery
Add native support for MongoDB as a new storage backend by implementing MongoDBStore, wiring it into configuration and factory logic, updating documentation and examples, and adding tests.
New Features:
Enhancements:
Documentation:
Tests:
Chores: