Giter VIP home page Giter VIP logo

go-mongr8's Introduction

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-present Authors and Contributors. Logo was created by Bing Chat.

Go-mongr8 is distributed under the MIT License.

go-mongr8's People

Contributors

amirkode avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

gungorfeyz

go-mongr8's Issues

[BUG] Cannot drop a complete field with nested fields

Issue:
A field remains exists after dropping it for a nested type like array or object

Step to reproduce:

  • Create a new nested field with this structure:
field.ArrayField("parent_field",
	field.ObjectField("",
		field.StringField("sub_field1"),
		field.DoubleField("sub_field1"),
	),
),
  • Generate and apply migration
  • Remove the field. Then, generate and apply the migration
  • The field parent_field must remain exist

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.