File: example_query_db_test.go

package info (click to toggle)
golang-gopkg-dancannon-gorethink.v1 1.4.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 764 kB
  • sloc: makefile: 3
file content (34 lines) | stat: -rw-r--r-- 758 bytes parent folder | download | duplicates (4)
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
package gorethink

import (
	"fmt"
)

// Create a database named ’superheroes’.
func ExampleDBCreate() {
	resp, err := 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
	DBCreate("superheroes").Exec(session)
	DB("superheroes").TableCreate("superheroes").Exec(session)
	DB("superheroes").TableCreate("battles").Exec(session)

	resp, err := 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
}