func InitDatabase(s *r.Session, databaseName string) error { exists, err := ListContains(s, r.DbList(), databaseName) if err != nil { return err } if !exists { err := r.DbCreate(databaseName).Exec(s) if err != nil { return err } } return nil }
// Check if the database has been setup func (db *RethinkDBAdapter) DbExists() (bool, *CASServerError) { cursor, err := r. DbList(). Run(db.session) if err != nil { casErr := &DbExistsCheckFailedError casErr.err = &err return false, casErr } var response []interface{} err = cursor.All(&response) // Check that the list contains the database name for the adapter for _, listedDb := range response { if listedDb == db.dbName { return true, nil } } return false, nil }