An open API service indexing awesome lists of open source software.

https://github.com/akmalfairuz/mgx

A Golang MongoDB API to simplify the use of MongoDB in your projects.
https://github.com/akmalfairuz/mgx

Last synced: about 1 month ago
JSON representation

A Golang MongoDB API to simplify the use of MongoDB in your projects.

Awesome Lists containing this project

README

        

# MongoX (mgx)

A Golang MongoDB API to simplify the use of MongoDB in your projects.

## Installation

```bash
go get github.com/akmalfairuz/mgx
```

### Example Usage

```go
package main

import (
"fmt"

"github.com/akmalfairuz/mgx"
)

func main() {
db, err := mgx.New("mongodb://localhost:27017", "test")
if err != nil {
panic(err)
}
r := db.Collection("users").Insert(mgx.M{
"name": "John Doe",
"age": 20,
}, mgx.NewInsertOneOptions().BypassDocumentValidation().Comment("John Doe user"))
if r.Err != nil {
panic(r.Err)
}
fmt.Println(r.InsertedID)
}