This project is still under initial development. A breaking change might happen anytime. Please, use it while watching for the latest update.
Go-mongr8 is a lightweight migration tool for MongoDB written in Go. This was inspired by SQL migration management in most application frameworks (i.e Django).
The project's philosophy is simplicity and efficiency, achieved by keeping everything at a high level. It simplifies the schema change process in MongoDB, allowing users to focus solely on the latest schema.
go get -u github.com/amirkode/go-mongr8@latest
For the CLI usage with go-mongr8
command, you can install globally:
go install github.com/amirkode/go-mongr8@latest
Basic operation can be done by using go-mongr8
CLI command. Complete documentation can be found here.
Users can easily define their schema with provided APis in this package. Here's the example of simple schema definition:
func (Users) Collection() collection.Metadata {
return metadata.InitMetadata("users")
}
func (Users) Fields() []collection.Field {
return []collection.Field{
field.StringField("name"),
field.Int32Field("age"),
}
}
func (Users) Indexes() []collection.Index {
return []collection.Index{
index.SingleFieldIndex(index.Field("name", 1)),
index.CompoundIndex(
index.Field("name", -1),
index.Field("age", 1),
),
}
}
Complete documentation can be found here.
- Dual-purpose: Use as CLI and as library.
- Lightweight migration tool with one-go CLI.
- Simplified and Descriptive schema declaration for ease of use.
- Covers common MongoDB migration operations.
- And much more coming soon.
- Init migration folder
- Init schema/collection
- Generate migration file
- Apply migration
- Consolidate migration
- Rollback migration
For supported MongoDB operations, you can see here.
As a disclaimer, This is an unofficial package designed for MongoDB Migration written in golang. As it relies on the MongoDB golang API, please be aware that some functionalities may evolve over time, potentially affecting compatibility with future MongoDB versions.
However, we will continue our efforts to provide support for future updates.
Coming soon
Copyright (c) 2023-present-present Authors and Contributors. Logo was created by Bing Chat.
Go-mongr8 is distributed under the MIT License.