Ejemplo n.º 1
0
func (self *Database) tableCreate(tableName string) {
	log.Printf(" - creating %s table\n", tableName)
	session := self.getSession()

	err := rethinkgo.TableCreate(tableName).Run(session).Exec()

	if err != nil {
		log.Println("[ERROR] tableCreate", err)
		panic(err)
	}
}
func setupDatabase() (err error) {
	err = rethink.DbCreate(TODO_DB).Run(session).Exec()
	if err != nil {
		// TODO: Check if the failure is that the database already exists
		return
	}

	err = rethink.TableCreate(TODO_TABLE).Run(session).Exec()
	if err != nil {
		// TODO: Check if the failure is that the table already exists
		return
	}
	return nil
}
func simpleTest() {
	session, err := r.Connect("localhost:28015", "test")
	if err != nil {
		log.Fatal(err)
	}

	/*

	  err = r.DbCreate("test").Run(session).Exec()
	  if err != nil {
	    log.Fatal(err)
	  }
	*/

	err = r.TableCreate("bookmarks").Run(session).Exec()
	if err != nil {
		log.Fatal(err)
	}
}
Ejemplo n.º 4
0
func initDb() {
	session, err := r.Connect(os.Getenv("WERCKER_RETHINKDB_URL"), "gettingstarted")
	if err != nil {
		log.Fatal(err)
		return
	}

	err = r.DbCreate("gettingstarted").Run(session).Exec()
	if err != nil {
		log.Println(err)
	}

	err = r.TableCreate("bookmarks").Run(session).Exec()
	if err != nil {
		log.Println(err)
	}

	sessionArray = append(sessionArray, session)
}
Ejemplo n.º 5
0
func (c *Connection) InitDatabase() {
	rethinkgo.DbCreate("magnet").Run(c.session).Exec()
	rethinkgo.TableCreate("users").Run(c.session).Exec()
	rethinkgo.TableCreate("bookmarks").Run(c.session).Exec()
	rethinkgo.TableCreate("sessions").Run(c.session).Exec()
}