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.
- Host: GitHub
- URL: https://github.com/akmalfairuz/mgx
- Owner: AkmalFairuz
- License: mit
- Created: 2023-03-18T11:52:56.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-25T09:23:49.000Z (about 2 years ago)
- Last Synced: 2025-04-06T13:45:55.779Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 mainimport (
"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)
}