Beispiel #1
0
func init() {
	// Mongo URL
	url, ok := config.GroupString("db", "mongoURL")
	if !ok {
		log.Fatal("wombat:apps:article: MongoURL missing from configuration")
	}

	// Database name
	db, ok := config.GroupString("db", "mongoDB")
	if !ok {
		db = "main"
	}

	col, ok := config.GroupString("db", "mongoCol")
	if !ok {
		col = "articles"
	}

	// Mongo error
	b, err := New(url, db, col)
	if err != nil {
		log.Fatal("Failed to create backend: %v", err)
	}

	// Register
	backends.Register("wombat:apps:article-reader", b)
	backends.Register("wombat:apps:article-printer", b)
}
Beispiel #2
0
func init() {
	if url, ok := config.GroupString("db", "mongoURL"); !ok {
		log.Fatal("users mongo: MongoURL missing from configuration")
	} else if session, err := mgo.Dial(url); err != nil {
		log.Fatal("Failed to retrieve Mongo session: ", err)
	} else {
		// set monotonic mode
		session.SetMode(mgo.Monotonic, true)
		// register backend
		b := Backend{session}
		backends.Register("mongo:user-reader", b)
		backends.Register("mongo:user-writer", b)
	}

	if d, ok := config.GroupString("db", "mongoDB"); ok {
		db = d
	}
}