Registry / database / kamva-mgm-v3

kamva-mgm-v3

JSON →
library3.5.0gogounverified

MongoDB Go Models (MGM) is a MongoDB ODM for Go, version 3.

go get github.com/kamva/mgm/v3
INSTALL
IMPORT
SIG · KAMVA-MGM-V3
K
kamva-mgm-v3
databasegov3.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mgm
github.com/kamva/mgm/v3

Connects to MongoDB and creates a new document using the MGM ODM.

package main import ( "context" "fmt" "log" "github.com/kamva/mgm/v3" "go.mongodb.org/mongo-driver/mongo/options" ) type User struct { mgm.DefaultModel `bson:",inline"` Name string `bson:"name"` } func main() { err := mgm.SetDefaultConfig(nil, "test", options.Client().ApplyURI("mongodb://localhost:27017")) if err != nil { log.Fatal(err) } user := &User{Name: "John"} err = mgm.Coll(user).Create(context.Background(), user) if err != nil { log.Fatal(err) } fmt.Printf("Created user: %+v\n", user) }
Debug
Known issues
breakingMGM v3 has breaking changes from v2, including configuration and model definition.
fix
Review the migration guide at https://github.com/Kamva/mgm#migration-from-v2-to-v3.
affects: >=3.0.0
Upgrade
Version history
3.5.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
14
Resources
kamva-mgm-v3 — go get kamva-mgm-v3 · libregistry