File: example_query_db_test.go

package info (click to toggle)
golang-gopkg-rethinkdb-rethinkdb-go.v6 6.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,736 kB
  • sloc: python: 1,382; makefile: 16; sh: 9
file content (35 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package tests

import (
	"fmt"
	r "gopkg.in/rethinkdb/rethinkdb-go.v6"
)

// Create a database named ’superheroes’.
func ExampleDBCreate() {
	resp, err := r.DBCreate("superheroes").RunWrite(session)
	if err != nil {
		fmt.Print(err)
	}

	fmt.Printf("%d DB created", resp.DBsCreated)
	// Output:
	// 1 DB created
}

// Drop a database named ‘superheroes’.
func ExampleDBDrop() {
	// Setup database + tables
	r.DBCreate("superheroes").Exec(session)
	r.DB("superheroes").TableCreate("superheroes").Exec(session)
	r.DB("superheroes").TableCreate("battles").Exec(session)

	resp, err := r.DBDrop("superheroes").RunWrite(session)
	if err != nil {
		fmt.Print(err)
	}

	fmt.Printf("%d DB dropped, %d tables dropped", resp.DBsDropped, resp.TablesDropped)
	// Output:
	// 1 DB dropped, 2 tables dropped
}