| 1 | package testsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.14 fmt/" |
| 5 | rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ "gopkg.in/rethinkdb/rethinkdb-go.v6scip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/" |
| 6 | ) |
| 7 | |
| 8 | // Return the first five squares. |
| 9 | func ExampleTerm_Mapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleTerm_Map().() { |
| 10 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Exprscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Expr().([]int{1, 2, 3, 4, 5}).Mapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Map().(func(val rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 11 | return val.Mulscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Mul().(val) |
| 12 | }).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 13 | if err != nil { |
| 14 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 15 | return |
| 16 | } |
| 17 | |
| 18 | var res []int |
| 19 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 20 | if err != nil { |
| 21 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 26 | |
| 27 | // Output: |
| 28 | // [1 4 9 16 25] |
| 29 | } |
| 30 | |
| 31 | // Sum the elements of three sequences. |
| 32 | func ExampleMap_multipleSequencesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleMap_multipleSequences().() { |
| 33 | var sequence1 = []int{100, 200, 300, 400} |
| 34 | var sequence2 = []int{10, 20, 30, 40} |
| 35 | var sequence3 = []int{1, 2, 3, 4} |
| 36 | |
| 37 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Mapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Map().(sequence1, sequence2, sequence3, func(val1, val2, val3 rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 38 | return val1.Addscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Add().(val2).Addscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Add().(val3) |
| 39 | }).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 40 | if err != nil { |
| 41 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | var res []int |
| 46 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 47 | if err != nil { |
| 48 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 53 | |
| 54 | // Output: |
| 55 | // [111 222 333 444] |
| 56 | } |
| 57 | |
| 58 | // Order all the posts using the index date. |
| 59 | func ExampleTerm_OrderBy_indexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleTerm_OrderBy_index().() { |
| 60 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.DBscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/DB().("examples").Tablescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Table().("posts").OrderByscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#OrderBy().(rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.OrderByOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#{ |
| 61 | Indexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#Index.: "date", |
| 62 | }).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 63 | if err != nil { |
| 64 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | var res []interface{} |
| 69 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 70 | if err != nil { |
| 71 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 76 | } |
| 77 | |
| 78 | // Order all the posts using the index date in descending order. |
| 79 | func ExampleTerm_OrderBy_indexDescscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleTerm_OrderBy_indexDesc().() { |
| 80 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.DBscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/DB().("examples").Tablescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Table().("posts").OrderByscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#OrderBy().(rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.OrderByOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#{ |
| 81 | Indexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#Index.: rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Descscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Desc().("date"), |
| 82 | }).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 83 | if err != nil { |
| 84 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 85 | return |
| 86 | } |
| 87 | |
| 88 | var res []interface{} |
| 89 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 90 | if err != nil { |
| 91 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 92 | return |
| 93 | } |
| 94 | |
| 95 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 96 | } |
| 97 | |
| 98 | // You can efficiently order using multiple fields by using a compound index. |
| 99 | // For example order by date and title. |
| 100 | func ExampleTerm_OrderBy_compoundscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleTerm_OrderBy_compound().() { |
| 101 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.DBscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/DB().("examples").Tablescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Table().("posts").OrderByscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#OrderBy().(rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.OrderByOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#{ |
| 102 | Indexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#Index.: rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Descscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Desc().("dateAndTitle"), |
| 103 | }).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 104 | if err != nil { |
| 105 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | var res []interface{} |
| 110 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 111 | if err != nil { |
| 112 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 113 | return |
| 114 | } |
| 115 | |
| 116 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 117 | } |
| 118 | |
| 119 | // If you have a sequence with fewer documents than the arrayLimit, you can order |
| 120 | // it by multiple fields without an index. |
| 121 | func ExampleTerm_OrderBy_multiplescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleTerm_OrderBy_multiple().() { |
| 122 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.DBscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/DB().("examples").Tablescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Table().("posts").OrderByscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#OrderBy().( |
| 123 | "title", |
| 124 | rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.OrderByOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#{Indexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#Index.: rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Descscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Desc().("date")}, |
| 125 | ).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 126 | if err != nil { |
| 127 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 128 | return |
| 129 | } |
| 130 | |
| 131 | var res []interface{} |
| 132 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 133 | if err != nil { |
| 134 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 135 | return |
| 136 | } |
| 137 | |
| 138 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 139 | } |
| 140 | |
| 141 | // Notice that an index ordering always has highest precedence. The following |
| 142 | // query orders posts by date, and if multiple posts were published on the same |
| 143 | // date, they will be ordered by title. |
| 144 | func ExampleTerm_OrderBy_multipleWithIndexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/ExampleTerm_OrderBy_multipleWithIndex().() { |
| 145 | cur, err := rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.DBscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/DB().("examples").Tablescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Table().("posts").OrderByscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#OrderBy().( |
| 146 | "title", |
| 147 | rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.OrderByOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#{Indexscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/OrderByOpts#Index.: rscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/.Descscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Desc().("date")}, |
| 148 | ).Runscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#Run().(sessionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests`/session.) |
| 149 | if err != nil { |
| 150 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 151 | return |
| 152 | } |
| 153 | |
| 154 | var res []interface{} |
| 155 | err = cur.Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(&res) |
| 156 | if err != nil { |
| 157 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(err) |
| 158 | return |
| 159 | } |
| 160 | |
| 161 | fmtscip-go gomod github.com/golang/go/src go1.14 fmt/.Printscip-go gomod github.com/golang/go/src go1.14 fmt/Print().(res) |
| 162 | } |