Debian Codegraph @

internal/integration/tests/example_query_db_test.go

raw symbols SCIP
1 package tests
2
3 import (
4 "fmt"
5 r "gopkg.in/rethinkdb/rethinkdb-go.v6"
6 )
7
8 // Create a database named ’superheroes’.
9 func ExampleDBCreate() {
10 resp, err := r.DBCreate("superheroes").RunWrite(session)
11 if err != nil {
12 fmt.Print(err)
13 }
14
15 fmt.Printf("%d DB created", resp.DBsCreated)
16 // Output:
17 // 1 DB created
18 }
19
20 // Drop a database named ‘superheroes’.
21 func ExampleDBDrop() {
22 // Setup database + tables
23 r.DBCreate("superheroes").Exec(session)
24 r.DB("superheroes").TableCreate("superheroes").Exec(session)
25 r.DB("superheroes").TableCreate("battles").Exec(session)
26
27 resp, err := r.DBDrop("superheroes").RunWrite(session)
28 if err != nil {
29 fmt.Print(err)
30 }
31
32 fmt.Printf("%d DB dropped, %d tables dropped", resp.DBsDropped, resp.TablesDropped)
33 // Output:
34 // 1 DB dropped, 2 tables dropped
35 }