https://github.com/night-codes/mgo-ai
Auto-increment methods for mgo(golang)
https://github.com/night-codes/mgo-ai
Last synced: 12 months ago
JSON representation
Auto-increment methods for mgo(golang)
- Host: GitHub
- URL: https://github.com/night-codes/mgo-ai
- Owner: night-codes
- License: wtfpl
- Created: 2016-02-22T15:40:53.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-29T12:04:02.000Z (almost 7 years ago)
- Last Synced: 2024-06-20T11:05:23.981Z (about 2 years ago)
- Language: Go
- Size: 3.91 KB
- Stars: 19
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mgo-autoincrement (ai)
Package **ai** implements AutoIncrement methods for mgo(golang)
## How To Install
```
go get github.com/night-codes/mgo-ai
```
## Getting Started
```go
package main
import (
"github.com/night-codes/mgo-ai"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
func main() {
session, err := mgo.Dial("localhost")
if err != nil {
panic(err)
}
// connect AutoIncrement to collection "counters"
ai.Connect(session.DB("example-db").C("counters"))
// ...
// use AutoIncrement
session.DB("example-db").C("users").Insert(bson.M{
"_id": ai.Next("users"),
"login": "test",
"age": 32,
})
}
```
## License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Oleksiy Chechel
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.