go-mongr8

command module
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 1 Imported by: 0

README

Logo

Go-mongr8

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.

Install

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

Usage

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.

Features

  • 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.
Functionalities
  • Init migration folder
  • Init schema/collection
  • Generate migration file
  • Apply migration
  • Consolidate migration
  • Rollback migration

For supported MongoDB operations, you can see here.

Limitations

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.

Contribution

Coming soon

License

Copyright (c) 2023-present Authors and Contributors. Logo was created by Bing Chat.

Go-mongr8 is distributed under the MIT License.

Documentation

Overview

Copyright (c) 2023 the go-mongr8 Author and Contributors [@see Authors file]

Licensed under the MIT License (https://opensource.org/licenses/MIT)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL