项目作者: siskinc

项目描述 :
golang orm for mongodb
高级语言: Go
项目地址: git://github.com/siskinc/mgorm.git
创建时间: 2019-04-05T13:32:08Z
项目社区:https://github.com/siskinc/mgorm

开源协议:

下载


mgorm

Getting Start

  1. $ go get -u github.com/siskinc/mgorm

Example

example file

Set Default Infomation

In a general way, we will only use one mongodb database, so we can set default infomation, some like mongodb host, database name, database auth infomation(username and password) and the time out second. So if you set these infomation, this package will generate default Session and Database Object.

Well, you can write the code by this way:

  1. err := mgorm.DefaultMgoInfo(
  2. "127.0.0.1:27017",
  3. "database_name",
  4. "username",
  5. "password",
  6. 30, // CollectionTimeoutSecond
  7. )

Cool, we havd set the default infomation of mongodb.

Now, we should study how to get a MongoDBClient for our Business Logic Layer.

In the above, we have set the default infomation of mongodb, we could just one parameter can get our MongoDBClient Object.

  1. client := mgorm.DefaultMongoDBClient("name")

Well, we get the client object, let’s curd! see the file example1.go