Mongo Go Models (mgm) is a fast and simple MongoDB ODM for Go (based on official Mongo Go Driver)

GoDoc Build Status

Mongo Go Models

Important Note: We changed package name from github.com/Kamva/mgm/v3(uppercase Kamva) to github.com/kamva/mgm/v3(lowercase kamva) in version 3.1.0 and future versions.

The Mongo ODM for Go

Features

  • Define your models and do CRUD operations with hooks before/after each operation.
  • mgm makes Mongo search and aggregation super easy to do in Golang.
  • Just set up your configs one time and get collections anywhere you need those.
  • mgm predefined all Mongo operators and keys, So you don't have to hardcode them.
  • The wrapper of the official Mongo Go Driver.

Requirements

  • Go 1.10 or higher.
  • MongoDB 2.6 and higher.

Install

Important Note: We changed package name from github.com/Kamva/mgm/v3(uppercase Kamva) to github.com/kamva/mgm/v3(lowercase kamva) in version 3.1.0 and future versions.

go get github.com/kamva/mgm/v3

Usage

To get started, import the mgm package, setup default config:

import (
   "github.com/kamva/mgm/v3"
   "go.mongodb.org/mongo-driver/mongo/options"
)

func init() {
   // Setup mgm default config
   err := mgm.SetDefaultConfig(nil, "mgm_lab", options.Client().ApplyURI("mongodb://root:12345@localhost:27017"))
}

Define your model:

type Book struct {
   // DefaultModel add _id,created_at and updated_at fields to the Model
   mgm.DefaultModel `bson:",inline"`
   Name             string `json:"name" bson:"name"`
   Pages            int    `json:"pages" bson:"pages"`
}

func NewBook(name string, pages int) *Book {
   return &Book{
      Name:  name,
      Pages: pages,
   }
}

Insert new document:

book:=NewBook("Pride and Prejudice", 345)

// Make sure pass the model by reference.
err := mgm.Coll(book).Create(book)

Find one document

//Get document's collection
book := &Book{}
coll := mgm.Coll(book)

// Find and decode doc to the book model.
_ = coll.FindByID("5e0518aa8f1a52b0b9410ee3", book)

// Get first doc of collection 
_ = coll.First(bson.M{}, book)

// Get first doc of collection with filter
_ = coll.First(bson.M{"page":400}, book)

Update document

// Find your book
book:=findMyFavoriteBook()

// and update it
book.Name="Moulin Rouge!"
err:=mgm.Coll(book).Update(book)

Delete document

// Just find and delete your document
err := mgm.Coll(book).Delete(book)

Find and decode result:

result := []Book{}

err := mgm.Coll(&Book{}).SimpleFind(&result, bson.M{"age": bson.M{operator.Gt: 24}})

Model's default fields

Each model by default (by using DefaultModel struct) has this fields:

  • _id : Document Id.

  • created_at: Creation date of doc. On save new doc, autofill by Creating hook.

  • updated_at: Last update date of doc. On save doc, autofill by Saving hook

Model's hooks:

Each model has these hooks :

  • Creating: Call on creating a new model.
    Signature : Creating() error

  • Created: Call on new model created.
    Signature : Created() error

  • Updating: Call on updating model.
    Signature : Updating() error

  • Updated : Call on models updated.
    Signature : Updated(result *mongo.UpdateResult) error

  • Saving: Call on creating or updating the model.
    Signature : Saving() error

  • Saved: Call on models Created or updated.
    Signature: Saved() error

  • Deleting: Call on deleting model.
    Signature: Deleting() error

  • Deleted: Call on models deleted.
    Signature: Deleted(result *mongo.DeleteResult) error

Notes about hooks:

  • Each model by default use the Creating and Saving hooks, So if you want to define those hooks, call to DefaultModel hooks in your defined hooks.
  • collection's methods which call to the hooks:
    • Create & CreateWithCtx
    • Update & UpdateWithCtx
    • Delete & DeleteWithCtx

Example:

func (model *Book) Creating() error {
   // Call to DefaultModel Creating hook
   if err:=model.DefaultModel.Creating();err!=nil{
      return err
   }

   // We can check if model fields is not valid, return error to
   // cancel document insertion .
   if model.Pages < 1 {
      return errors.New("book must have at least one page")
   }

   return nil
}

config :

mgm default config contains context timeout:

func init() {
   _ = mgm.SetDefaultConfig(&mgm.Config{CtxTimeout:12 * time.Second}, "mgm_lab", options.Client().ApplyURI("mongodb://root:12345@localhost:27017"))
}

// To get context , just call to Ctx() method.
ctx:=mgm.Ctx()

// Now we can get context by calling to `Ctx` method.
coll := mgm.Coll(&Book{})
coll.FindOne(ctx,bson.M{})

// Or call it without assign variable to it.
coll.FindOne(mgm.Ctx(),bson.M{})

Collection

Get model collection:

coll:=mgm.Coll(&Book{})

// Do something with the collection

mgm automatically detect model's collection name:

book:=Book{}

// Print your model collection name.
collName := mgm.CollName(&book)
fmt.Println(collName) // print: books

You can also set custom collection name for your model by implementing CollectionNameGetter interface:

func (model *Book) CollectionName() string {
   return "my_books"
}

// mgm return "my_books" collection
coll:=mgm.Coll(&Book{})

Get collection by its name (without need of defining model for it):

coll := mgm.CollectionByName("my_coll")
   
//Do Aggregation,... with collection

Customize model db by implementing CollectionGetter interface:

func (model *Book) Collection() *mgm.Collection {
    // Get default connection client
   _,client,_, err := mgm.DefaultConfigs()

   if err != nil {
      panic(err)
   }

   db := client.Database("another_db")
   return mgm.NewCollection(db, "my_collection")
}

Or return model collection from another connection:

func (model *Book) Collection() *mgm.Collection {
   // Create new client
   client, err := mgm.NewClient(options.Client().ApplyURI("mongodb://root:12345@localhost:27017"))

   if err != nil {
      panic(err)
   }

   // Get model db
   db := client.Database("my_second_db")

   // return model custom collection
   return mgm.NewCollection(db, "my_collection")
}

Aggregation

while we can haveing Mongo Go Driver Aggregate features, mgm also provide simpler methods to aggregate:

Run aggregate and decode result:

authorCollName := mgm.Coll(&Author{}).Name()
result := []Book{}


// Lookup in just single line
_ := mgm.Coll(&Book{}).SimpleAggregate(&result, builder.Lookup(authorCollName, "auth_id", "_id", "author"))

// Multi stage(mix of mgm builders and raw stages)
_ := mgm.Coll(&Book{}).SimpleAggregate(&result,
		builder.Lookup(authorCollName, "auth_id", "_id", "author"),
		M{operator.Project: M{"pages": 0}},
)

// Do something with result...

Do aggregate using mongo Aggregation method:

import (
   "github.com/kamva/mgm/v3"
   "github.com/kamva/mgm/v3/builder"
   "github.com/kamva/mgm/v3/field"
   . "go.mongodb.org/mongo-driver/bson"
   "go.mongodb.org/mongo-driver/bson/primitive"
)

// Author model collection
authorColl := mgm.Coll(&Author{})

cur, err := mgm.Coll(&Book{}).Aggregate(mgm.Ctx(), A{
    // S function get operators and return bson.M type.
    builder.S(builder.Lookup(authorColl.Name(), "author_id", field.Id, "author")),
})

More complex and mix with mongo raw pipelines:

import (
   "github.com/kamva/mgm/v3"
   "github.com/kamva/mgm/v3/builder"
   "github.com/kamva/mgm/v3/field"
   "github.com/kamva/mgm/v3/operator"
   . "go.mongodb.org/mongo-driver/bson"
   "go.mongodb.org/mongo-driver/bson/primitive"
)

// Author model collection
authorColl := mgm.Coll(&Author{})

_, err := mgm.Coll(&Book{}).Aggregate(mgm.Ctx(), A{
    // S function get operators and return bson.M type.
    builder.S(builder.Lookup(authorColl.Name(), "author_id", field.Id, "author")),
    builder.S(builder.Group("pages", M{"books": M{operator.Push: M{"name": "$name", "author": "$author"}}})),
    M{operator.Unwind: "$books"},
})

if err != nil {
    panic(err)
}

Transaction

  • To run a transaction on default connection use mgm.Transaction() function, e.g:
d := &Doc{Name: "Mehran", Age: 10}

err := mgm.Transaction(func(session mongo.Session, sc mongo.SessionContext) error {

       // do not forget to pass the session's context to the collection methods.
	err := mgm.Coll(d).CreateWithCtx(sc, d)

	if err != nil {
		return err
	}

	return session.CommitTransaction(sc)
})
  • To run a transaction with your context, use mgm.TransactionWithCtx() method.
  • To run a transaction on another connection, use mgm.TransactionWithClient() method.

Mongo Go Models other packages

We implemented these packages to simplify query and aggregate in mongo

builder: simplify mongo query and aggregation.

operator : contain mongo operators as predefined variable.
(e.g Eq = "$eq" , Gt = "$gt")

field : contain mongo fields using in aggregation and ... as predefined variable. (e.g LocalField = "localField", ForeignField = "foreignField")

example:

import (
  "github.com/kamva/mgm/v3"
  f "github.com/kamva/mgm/v3/field"
  o "github.com/kamva/mgm/v3/operator"
  "go.mongodb.org/mongo-driver/bson"
)

// Instead of hard-coding mongo operators and fields 
_, _ = mgm.Coll(&Book{}).Aggregate(mgm.Ctx(), bson.A{
   bson.M{"$count": ""},
   bson.M{"$project": bson.M{"_id": 0}},
})

// Use predefined operators and pipeline fields.
_, _ = mgm.Coll(&Book{}).Aggregate(mgm.Ctx(), bson.A{
   bson.M{o.Count: ""},
   bson.M{o.Project: bson.M{f.Id: 0}},
})

Bugs / Feature request

New Features and bugs can be reported on Github issue tracker.

Communicate With Us

Contributing

Open in Gitpod

  1. Fork the repository
  2. Clone your fork (git clone https://github.com/<your_username>/mgm && cd mgm)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make changes and add them (git add .)
  5. Commit your changes (git commit -m 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new pull request

License

Mongo Go Models is released under the Apache License

Comments
  • Mock package

    Mock package

    I am loving mgm! I am also willing to help contribute to make it better.

    I think adding a mock package to make mocking the DB easier would be a great improvement to this project

  • Get Create inserted ID

    Get Create inserted ID

    Hello,

    I would like to retrieve the ID of the fresh inserted document.

    Taking this snippet from the documentation:

    book := NewBook("Pride and Prejudice", 345)
    
    // Make sure to pass the model by reference.
    err := mgm.Coll(book).Create(book)
    

    I would like to retrieve the "book" ID, how can i do this without perform another search ?

    Best regards

  • CreatedAt is overwritten with a zero value during Save

    CreatedAt is overwritten with a zero value during Save

    Describe the bug

    I have a model with the DefaultModel included.

    I have a method which does something like the following:

    func  Update(dto dto.MyModel) error {
            // Convert from a DTO
    	m, err := (&MyModel{}).FromDTO(dto)
    	if err != nil {
    		return fmt.Errorf("converting from DTO: %w", err)
    	}
    
    	if err := m.Save(); err != nil {
    		return fmt.Errorf("saving model: %w", err)
    	}
    
    	return nil
    }
    

    The conversion from a DTO leaves CreatedAt as the zero-value, because that info is left out of my DTOs.

    The problem is that CreatedAt is not declared as omitempty, so when I .Save() like this, it is overwritten with a zero value.

    To Reproduce Steps to reproduce the behavior:

    1. Create a document
    2. Instantiate another document struct with the same primary key and set CreatedAt to nothing (or anything you want)
    3. Save the document

    Expected behavior

    Changes to CreatedAt are ignored, or at least ignored if CreatedAt is the zero value of time.Time.

    Screenshots

    N/A

    Environment (please complete the following information):

    • OS: a Docker container running golang:bullseye

    Additional context

    As a workaround, I can stick to a get-modify-save pattern where I save the original CreatedAt time and restore it before the save instead of attempting to directly update/upsert.

  • Type safe partial updates?

    Type safe partial updates?

    Let's say you have this model:

    type Book struct {
      mgm.DefaultModel `bson:",inline"`
    
      Author string `bson:"author"`
    
      // ... more fields ...
    }
    

    Somewhere in your code you want to change the author's name, so you have:

    book := &Book{}
    _, err := mgm.Coll(book).UpdateOne(mgm.Ctx(), bson.M{
      "_id": id
    }, bson.M{
      "$set": bson.M{
        "author": authorName,
      },
    })
    

    Time goes on, the codebase grows, many contributors, and the realization is made that a book can have multiple authors, so the model is changed to:

    type Book struct {
      mgm.DefaultModel `bson:",inline"`
    
      Authors []string `bson:"authors"`
    
      // ... more fields ...
    }
    

    The update code won't throw any sort of error or warning because there is no type safety. Without many lines of code to perform tag reflection (and even more lines if it's a nested field), is there a clean way to make a partial update to a model where type safety is preserved?

  • Auth fails with mongodb atlas cluster

    Auth fails with mongodb atlas cluster

    Describe the bug "connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AtlasError) Authentication failed.

    Everything was working fine till today I get error with authentication failed. I didn't changed anything, not a single line of code but still I get error on any operation with mgm connection() : auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": (AtlasError) Authentication failed.

    To Reproduce Steps to reproduce the behavior: 1.

    err = mgm.SetDefaultConfig(nil, "directory", options.Client().ApplyURI(os.Getenv("MONGODB_URI")))
    if err != nil {
    	log.Fatal(err)
    }
    
    1. Export MONGODB_URI with mongodb atlas cluster uri.
    2. Run the server.
    3. Do Some operation.

    Expected behavior Operation should complete without any error.

    Environment (please complete the following information):

    • OS: Ubuntu 20.04
  • Removed interface{} as a return type for Get/Set/PrepareID

    Removed interface{} as a return type for Get/Set/PrepareID

    The following functions GetID, SetID and PrepareID all know there return type... There is no need to return a interface{} as this causes unneeded casting by anyone using the package.

    Also cleaned up some of the reflection in those functions above to make them "smarter" using switch on type.

    This makes it always assume we can take either a string (gets converted) or a primitive.ObjectID

  • Mgm.Update is not working properly

    Mgm.Update is not working properly

    While creating a new data using mgm.create method, its successfully created the data with created at and updated at details in defaultmodel field. But While updating the data using updateOne or FindOneandUpdate, its successfully updated but the created at and Updated at field details became 0001-01-01T00:00:00.000+00:00 in the database. I know, here i am using mongo drive function so that defaultmodel fields are not accessed so that the created at and updated at becames 0001-01-01T00:00:00.000+00:00.

    why I am using mongo drive function because while update using mgm.update, there is only one parameter as model. so I find the data which i need to update and manually map the details and send the parameter to that function. Even though, it's not updating properly in database.

    Expected behavior:

    1. please provide an extra filter parameter to update function in mgm. so that it will be easy to use mgm.update function Or tell us how to use the mgm.update function, Because the Previous information provided by you is not clear.

    Environment (please complete the following information):

    • OS: Ubuntu
  • Added context support in hooks

    Added context support in hooks

    Have added support for passing context in hooks. This tackles this issue

    Have added new interfaces for hooks like OldNameWithCtx e.g (CreatingHookWithCtx) and have deprecated the old interface. This was done to support the backward compatibility

    The new Interfaces follow the same func names but additionally takes a context field

    // CreatingHookWithCtx is called before saving a new model to the database
    type CreatingHookWithCtx interface {
    	Creating(context.Context) error
    }
    

    Have added appropriate test as well in hooks_test.go file

  • Get All from a collection

    Get All from a collection

    Describe the bug

    Syntax is wrong

    result := []Book{}
    
    err := mgm.Coll(&Book{}).SimpleFind(&result, bson.M{"age": bson.M{operator.Gt: 24}})
    

    Should be:

    result := []Book
    
    err := mgm.Coll(&Book{}).SimpleFind(&result, bson.M{"age": bson.M{operator.Gt: 24}})
    

    Or maybe i miss something ?

    Additionnaly, maybe add the FindAll method example:

    	var result []Book
    
    	err := collection.SimpleFind(&result, bson.D{})
    
    	log.Fatalf("here is the books: %v", result)
    

    best regards

  • Updating by id fails to find document in update query

    Updating by id fails to find document in update query

    Describe the bug I'm building a simple CRUD API, and when trying to use the "FindOneAndUpdate" method, it's not completing the update call when passing in the document id as a filter parameter

    Models:

    type Car struct{
    	CarName   string  `json:"car_name"   bson:"car_name"`
    	Make      string  `json:"make"       bson:"make"`
    	ModelYear int     `json:"model_year" bson:"model_year"`
    	CarType   string  `json:"car_type"   bson:"car_type"`
    	Price     float64 `json:"price"      bson:"price"`
    }
    
    
    type User struct{
    	mgm.DefaultModel `bson:",inline"`
    	Name            string `json:"name" bson:"name"`
    	FavoriteCarType string `json:"favorite_car_type" bson:"favorite_car_type"`
    	FavoriteCar     string `json:"favorite_car" bson:"favorite_car"`
    	FavoriteCars    []Car  `json:"favorite_cars" bson:"favorite_cars"`
    }
    

    Update user method:

    type UserController struct{
    	router *mux.Router
    }
    
    func (u *UserController) updateUser(res http.ResponseWriter, req *http.Request){
    	id := mux.Vars(req)["id"]
    	user := bson.M{}
    
    	json.NewDecoder(req.Body).Decode(&user)
    
    	result := mgm.Coll(&model.User{}).FindOneAndUpdate(mgm.Ctx(), bson.M{"_id": id}, bson.M{"$set": user})
    
            //The above method call causes the following error message to be returned
    	if result.Err() != nil{
    		utilities.SendJSON(http.StatusNotFound, res, utilities.M{"message":  result.Err().Error()})
    		return
    	}
    
    	utilities.SendJSON(200, res, utilities.M{"result": result})
    }
    

    Update query (Postman):

    
    {
        "favorite_car_type": "performance van",
        "favorite_car": "Pacifica SRT"
    }
    
    

    route to "updateUser()" method: localhost:8080/users/{id}

    Utilities:

    type M map[string]interface{} 
    
    //SendJSON - Utility function to send JSON
    func SendJSON(statusCode int, res http.ResponseWriter, body interface{}){
    	res.Header().Set("Content-Type", "application/json")
    	res.WriteHeader(statusCode)
    	json.NewEncoder(res).Encode(body)
    	
    	return
    }
    
    
    

    When getting a user by id by calling the FindByID method:

     id := mux.Vars(req)["id"]
    	user := model.User{}
    
    	//find all the user in the "users" collection who have "id" as their favorite car type
    	result := mgm.Coll(&model.User{}).FindByID(id, &user)
    
    

    the above code works, but for the updateUser method, the error block is hit every time. Is there something I'm missing?

  • ID, created_at, updated_at is not generated with nested field

    ID, created_at, updated_at is not generated with nested field

    Describe the bug When using mgm model with mgm.DefaultModel in nested struct inside model, ID, created_at and updated_at of this struct is not updated when using Save() and Update().

    To Reproduce Save/Update model with nested struct that has mgm.DefaultModel. Saved/Updated collection does have null _id, created_at and updated_at fields.

    Example model:

    type GameReview struct {
      mgm.DefaultModel `bson:",inline"`
      Content string `bson:"content"`
    }
    
    type Game struct {
      mgm.DefaultModel  `bson:",inline"`
      Name string `bson:"name"`
    }
    

    Expected behavior ID, created_at and updated_at fields should be updated.

    Environment (please complete the following information):

    • Ubuntu 20.04
    • go1.14.7

    Due to the nature of the error, it will occur on every environment.

  • Authentication Failure

    Authentication Failure

    Describe the bug Authentication error when trying to connect to Mongo. I get the following error when trying to connect to mongo using user credentials -

    {
        "error": "connection() error occured during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-1\": (AuthenticationFailed) Authentication failed.",
        "ok": false
    }
    

    I am able to login via mongo-shell using the same creds as in the screenshot below. However the ORM throws error -

    Screenshot 2022-02-26 at 6 45 08 PM

    Note: This is similar to this closed issue.

    To Reproduce Steps to reproduce the behavior:

    1. Create a test user with the following creds -
      MONGODB_PORT="27017"
      MONGODB_URL="localhost"
      MONGODB_USERNAME="test"
      MONGODB_PASSWORD="test123"
      MONGODB_DB="todos"
      
    2. Connect to mongo using the ODM
      	package main
      
      	import (
      		"log"
      
      		"github.com/Kamva/mgm/v2"
      		"go.mongodb.org/mongo-driver/mongo/options"
      	)
      
      	func init() {
      		err = mgm.SetDefaultConfig(nil, "todos", options.Client().ApplyURI("mongodb://test:test123@localhost:27017"))
      		if err != nil {
      			log.Fatal("Error setting default config")
      			log.Fatal(err)
      		}
      	}
      

    Expected behavior Connection should not fail when trying to connect via above piece of code

    Screenshots If applicable, add screenshots to help explain your problem.

    Environment (please complete the following information):

    • OS: MacOS Big Sur
    • Mongo: v5.0.6

    Additional context Add any other context about the problem here.

  • Add support for Create, Update and Delete multiple entries with hooks

    Add support for Create, Update and Delete multiple entries with hooks

    Is your feature request related to a problem? Please describe.

    • Problem
      • Currently, hook is supported only for the following methods.
        • Create & CreateWithCtx
        • Update & UpdateWithCtx
        • Delete & DeleteWithCtx
      • This is inconvenient to create/update/delete multiple entries as the hook support does not exist. One must loop over the above methods to operate over multiple entries.
      • It's difficult to perform atomic operations and rollback (when dealing with multiple entries), if using just the above mentioned function, as one must define transaction and so on, creating verbose code.

    Describe the solution you'd like

    • Add support for methods that allows creating/updating/deleting multiple entries, with support for hooks.

    Describe alternatives you've considered

    • Currently the solution with the above mentioned methods include,
      • Looping over the methods to perform batch operations
      • Wrapping batch operation in transaction, so that rollback can be performed in case of failure
      • Using native methods (e.g. InsertMany, UpdateMany, DeleteMany). But, hook support does not exist.

    Additional context

    • N/A
  • Change tracking for updates

    Change tracking for updates

    Is your feature request related to a problem? Please describe. When saving an update to a model, the entire document is overwritten in the database, as opposed to only the fields that have changed, which could open you up to concurrency issues. Tracking changes can also be useful when implementing something like audit log.

    Describe the solution you'd like An update that only $sets the changed fields and a function API (e.g. model.HasChanged("FieldName")) to check what fields have changed in the hooks.

    Describe alternatives you've considered I'm not sure how this could implemented without changes to mgm, but open to ideas for sure!

    Additional context Would you all be open to a PR to add this if I put some work into it?

  • Optimistic locking

    Optimistic locking

    Hi,

    I needed to have optimistic locking behavior on my project so implemented it in this pull request. It is based on a version field that gets incremented when saving. It can also be done through an updatedOn field but this PR uses the version technique for the DefaultModel.

    It works the following way : A new field called "Version" has been added to DefaultModel (saves to "version" in the db) Models have to implement a Versionable interface so that the behavior kicks in. DefaultModel implements it and so documents using the DefaultModel will have this enabled by default). This interface has 3 methods : GetVersion() -> returns the version number of this document IncrementVersion() -> responsible for updating the version number GetVersionFieldName() -> returns the name of the field that holds the version number

    Then when the actual update is called, we can simply check that in the query part of the udpate that the version is the same as when the document was retrieved. If not, a custom error is raised.

  • Query builder

    Query builder

    Hey, first of all, great project!

    Is your feature request related to a problem? Please describe. One of the most annoying things about MongoDB and GOlang is querying.

    Describe the solution you'd like I would like to see a query build that is simple enough and doesn't involve bson. For example

    q := Query("field1", "value1") // optional "and"
    q.And("field2", "value2").And("field3", "value3")
      .And(Query("foo1", "v1").Or("foo2", "v2"))
    

    This would greatly simplify most generic queries.

Go-odm, a Golang Object Document Mapping for MongoDB.
Go-odm, a Golang Object Document Mapping for MongoDB.

A project of SENROK Open Source Go ODM Go-odm, a Golang Object Document Mapping for MongoDB. Table of contents Features Installation Get started Docum

Nov 4, 2022
Go-mongodb - Practice Go with MongoDB because why not

Practice Mongo DB with Go Because why not. Dependencies gin-gonic go mongodb dri

Jan 5, 2022
The MongoDB driver for Go

The MongoDB driver for Go This fork has had a few improvements by ourselves as well as several PR's merged from the original mgo repo that are current

Jan 8, 2023
The Go driver for MongoDB
The Go driver for MongoDB

MongoDB Go Driver The MongoDB supported driver for Go. Requirements Installation Usage Bugs / Feature Reporting Testing / Development Continuous Integ

Dec 31, 2022
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

Go-MySQL-Driver A MySQL-Driver for Go's database/sql package Features Requirements Installation Usage DSN (Data Source Name) Password Protocol Address

Jan 4, 2023
Go driver for PostgreSQL over SSH. This driver can connect to postgres on a server via SSH using the local ssh-agent, password, or private-key.

pqssh Go driver for PostgreSQL over SSH. This driver can connect to postgres on a server via SSH using the local ssh-agent, password, or private-key.

Nov 6, 2022
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)

gokv Simple key-value store abstraction and implementations for Go Contents Features Simple interface Implementations Value types Marshal formats Road

Dec 24, 2022
Examples and code to assign a name to your MongoDB, MySQL, PostgreSQL, RabbitMQ, and redis connection.
Examples and code to assign a name to your MongoDB, MySQL, PostgreSQL, RabbitMQ, and redis connection.

your connection deserves a name ?? When your app interacts with an external system, assign a name to the connection. An external system in this contex

Dec 14, 2022
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.

upper/db is a productive data access layer (DAL) for Go that provides agnostic tools to work with different data sources

Jan 3, 2023
A MongoDB compatible embeddable database and toolkit for Go.
A MongoDB compatible embeddable database and toolkit for Go.

lungo A MongoDB compatible embeddable database and toolkit for Go. Installation Example Motivation Architecture Features License Installation To get s

Jan 3, 2023
💲 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions
💲 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions

Bank Projeto para simular empréstimos financeiros em um banco para clientes Tecnologias Utilizadas Golang MongoDB RabbitMQ Github Actions Docker Hub D

Dec 9, 2022
Golang MongoDB Integration Examples

Get Program Get a copy of the program: git clone https://github.com/hmdhszd/Go

Feb 1, 2022
PostgreSQL driver and toolkit for Go

pgx - PostgreSQL Driver and Toolkit pgx is a pure Go driver and toolkit for PostgreSQL. pgx aims to be low-level, fast, and performant, while also ena

Jan 4, 2023
Mirror of Apache Calcite - Avatica Go SQL Driver

Apache Avatica/Phoenix SQL Driver Apache Calcite's Avatica Go is a Go database/sql driver for the Avatica server. Avatica is a sub-project of Apache C

Nov 3, 2022
Firebird RDBMS sql driver for Go (golang)

firebirdsql (Go firebird sql driver) Firebird RDBMS http://firebirdsql.org SQL driver for Go Requirements Firebird 2.5 or higher Golang 1.13 or higher

Dec 20, 2022
Microsoft ActiveX Object DataBase driver for go that using exp/sql

go-adodb Microsoft ADODB driver conforming to the built-in database/sql interface Installation This package can be installed with the go get command:

Dec 30, 2022
Microsoft SQL server driver written in go language

A pure Go MSSQL driver for Go's database/sql package Install Requires Go 1.8 or above. Install with go get github.com/denisenkom/go-mssqldb . Connecti

Dec 26, 2022
Oracle driver for Go using database/sql

go-oci8 Description Golang Oracle database driver conforming to the Go database/sql interface Installation Install Oracle full client or Instant Clien

Dec 30, 2022
sqlite3 driver for go using database/sql

go-sqlite3 Latest stable version is v1.14 or later not v2. NOTE: The increase to v2 was an accident. There were no major changes or features. Descript

Jan 8, 2023