예제 #1
0
func NewVotingHandler(conn, dbName string) (*VotingDataHandler, error) {
	dbh := d.NewDbHelper(conn, dbName)
	if dbh.Check() {
		result := VotingDataHandler{DbHelper: *dbh}
		result.ensureIndexes()
		return &result, nil
	}
	return nil, errors.New("Can not connect to db, try it next time")
}
func getDbsWithOrders() []string {
	dbHelper := d.NewDbHelper(config.Main.Database.ConnString, "local")
	result := []string{}
	if names, err := dbHelper.Session.DatabaseNames(); err == nil {
		for _, dbName := range names {
			collections, err := dbHelper.Session.DB(dbName).CollectionNames()
			if err != nil {
				continue
			}
			if utils.InS("orders", collections) {
				result = append(result, dbName)
			}
		}
	}
	return result
}
예제 #3
0
func NewQuestStorage(conn, dbname string) *QuestStorage {
	helper := db.NewDbHelper(conn, dbname)
	result := QuestStorage{DbHelper: *helper}
	result.ensureIndexes()
	return &result
}