mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
added blog example
This commit is contained in:
20
examples/blog/database/database.go
Normal file
20
examples/blog/database/database.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package database
|
||||
|
||||
import "gopkg.in/mgo.v2"
|
||||
|
||||
type Database struct {
|
||||
Session *mgo.Session
|
||||
}
|
||||
|
||||
func New(uri string) *Database {
|
||||
session, err := mgo.Dial(uri)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
session.SetMode(mgo.Monotonic, true)
|
||||
|
||||
return &Database{
|
||||
Session: session,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user