Skip to content

zjuxlab/Mongorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongorm

An ORM Framework for go-mongo

How to Use

// 1. init database
ConnectMongo(...)

// 2. init collection binding
// store all `Person` in `db.COL_People`
SetCollectionByName[Person]("COL_People")

// 3. enjoy CRUD
val, ok := Mongorm.FindOne[Person](bson.M{"Name": "xxx"}) 
// or Replace, Delete, ...

To Begin With

Threr are 3 types to bind Mongo-Collections with Go-Type

  1. ConnectMongo then SetCollectionByName(col_name)
  2. ConnectMongo and defaults to use reflect.Type.Name() as collection name
  3. Init Mongo elsewhere and SetCollection(col)

Dependency

About

An ORM Framework for go-mongo using Generics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages