{"id":37135198,"url":"https://github.com/unloop/gorethink","last_synced_at":"2026-01-14T15:46:19.844Z","repository":{"id":57593405,"uuid":"76656284","full_name":"unloop/gorethink","owner":"unloop","description":"Go language driver for RethinkDB","archived":false,"fork":true,"pushed_at":"2016-12-16T13:41:32.000Z","size":1862,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T12:03:32.946Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rethinkdb/rethinkdb-go","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unloop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-16T13:35:53.000Z","updated_at":"2018-09-11T21:39:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/unloop/gorethink","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/unloop/gorethink","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unloop%2Fgorethink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unloop%2Fgorethink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unloop%2Fgorethink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unloop%2Fgorethink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unloop","download_url":"https://codeload.github.com/unloop/gorethink/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unloop%2Fgorethink/sbom","scorecard":{"id":910757,"data":{"date":"2025-08-11","repo":{"name":"github.com/unloop/gorethink","commit":"863692d8128ffad745290fb220da75ad01910e16"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-24T19:03:16.514Z","repository_id":57593405,"created_at":"2025-08-24T19:03:16.514Z","updated_at":"2025-08-24T19:03:16.514Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T15:46:19.139Z","updated_at":"2026-01-14T15:46:19.833Z","avatar_url":"https://github.com/unloop.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoRethink - RethinkDB Driver for Go\n\n[![GitHub tag](https://img.shields.io/github/tag/gorethink/gorethink.svg?style=flat)](https://github.com/gorethink/gorethink/releases)\n[![GoDoc](https://godoc.org/github.com/gorethink/gorethink?status.png)](https://godoc.org/github.com/gorethink/gorethink)\n[![build status](https://img.shields.io/travis/gorethink/gorethink/master.svg \"build status\")](https://travis-ci.org/gorethink/gorethink)\n[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n[Go](http://golang.org/) driver for [RethinkDB](http://www.rethinkdb.com/)\n\n![GoRethink Logo](https://raw.github.com/wiki/gorethink/gorethink/gopher-and-thinker-s.png \"Golang Gopher and RethinkDB Thinker\")\n\nCurrent version: v3.0.0 (RethinkDB v2.3)\n\nThis project is no longer maintained, for more information see the [v3.0.0 release](https://github.com/gorethink/gorethink/releases/tag/v3.0.0)\n\nPlease note that this version of the driver only supports versions of RethinkDB using the v0.4 protocol (any versions of the driver older than RethinkDB 2.0 will not work).\n\nIf you need any help you can find me on the [RethinkDB slack](http://slack.rethinkdb.com/) in the #gorethink channel.\n\n## Installation\n\n```\ngo get gopkg.in/gorethink/gorethink.v2\n```\n\n(Or v1)\n\n```sh\ngo get gopkg.in/gorethink/gorethink.v1\n```\n\n## Example\n\n[embedmd]:# (example_test.go go)\n```go\npackage gorethink_test\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\tr \"gopkg.in/gorethink/gorethink.v2\"\n)\n\nfunc Example() {\n\tsession, err := r.Connect(r.ConnectOpts{\n\t\tAddress: url,\n\t})\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tres, err := r.Expr(\"Hello World\").Run(session)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tvar response string\n\terr = res.One(\u0026response)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tfmt.Println(response)\n\n\t// Output:\n\t// Hello World\n}\n```\n\n## Connection\n\n### Basic Connection\n\nSetting up a basic connection with RethinkDB is simple:\n\n[embedmd]:# (example_connect_test.go go /func ExampleConnect\\(\\) {/ /(?m)^}/)\n```go\nfunc ExampleConnect() {\n\tvar err error\n\n\tsession, err = r.Connect(r.ConnectOpts{\n\t\tAddress: url,\n\t})\n\tif err != nil {\n\t\tlog.Fatalln(err.Error())\n\t}\n}\n```\n\nSee the [documentation](http://godoc.org/github.com/gorethink/gorethink#Connect) for a list of supported arguments to Connect().\n\n### Connection Pool\n\nThe driver uses a connection pool at all times, by default it creates and frees connections automatically. It's safe for concurrent use by multiple goroutines.\n\nTo configure the connection pool `InitialCap`, `MaxOpen` and `Timeout` can be specified during connection. If you wish to change the value of `InitialCap` or `MaxOpen` during runtime then the functions `SetInitialPoolCap` and `SetMaxOpenConns` can be used.\n\n[embedmd]:# (example_connect_test.go go /func ExampleConnect_connectionPool\\(\\) {/ /(?m)^}/)\n```go\nfunc ExampleConnect_connectionPool() {\n\tvar err error\n\n\tsession, err = r.Connect(r.ConnectOpts{\n\t\tAddress:    url,\n\t\tInitialCap: 10,\n\t\tMaxOpen:    10,\n\t})\n\tif err != nil {\n\t\tlog.Fatalln(err.Error())\n\t}\n}\n```\n\n### Connect to a cluster\n\nTo connect to a RethinkDB cluster which has multiple nodes you can use the following syntax. When connecting to a cluster with multiple nodes queries will be distributed between these nodes.\n\n[embedmd]:# (example_connect_test.go go /func ExampleConnect_cluster\\(\\) {/ /(?m)^}/)\n```go\nfunc ExampleConnect_cluster() {\n\tvar err error\n\n\tsession, err = r.Connect(r.ConnectOpts{\n\t\tAddresses: []string{url},\n\t\t//  Addresses: []string{url1, url2, url3, ...},\n\t})\n\tif err != nil {\n\t\tlog.Fatalln(err.Error())\n\t}\n}\n```\n\nWhen `DiscoverHosts` is true any nodes are added to the cluster after the initial connection then the new node will be added to the pool of available nodes used by GoRethink. Unfortunately the canonical address of each server in the cluster **MUST** be set as otherwise clients will try to connect to the database nodes locally. For more information about how to set a RethinkDB servers canonical address set this page http://www.rethinkdb.com/docs/config-file/.\n\n## User Authentication\n\nTo login with a username and password you should first create a user, this can be done by writing to the `users` system table and then grant that user access to any tables or databases they need access to. This queries can also be executed in the RethinkDB admin console.\n\n```go\nerr := r.DB(\"rethinkdb\").Table(\"users\").Insert(map[string]string{\n    \"id\": \"john\",\n    \"password\": \"p455w0rd\",\n}).Exec(session)\n...\nerr = r.DB(\"blog\").Table(\"posts\").Grant(\"john\", map[string]bool{\n    \"read\": true,\n    \"write\": true,\n}).Exec(session)\n...\n```\n\nFinally the username and password should be passed to `Connect` when creating your session, for example:\n\n```go\nsession, err := r.Connect(r.ConnectOpts{\n    Address: \"localhost:28015\",\n    Database: \"blog\",\n    Username: \"john\",\n    Password: \"p455w0rd\",\n})\n```\n\nPlease note that `DiscoverHosts` will not work with user authentication at this time due to the fact that RethinkDB restricts access to the required system tables.\n\n## Query Functions\n\nThis library is based on the official drivers so the code on the [API](http://www.rethinkdb.com/api/) page should require very few changes to work.\n\nTo view full documentation for the query functions check the [API reference](https://github.com/gorethink/gorethink/wiki/Go-ReQL-command-reference) or [GoDoc](http://godoc.org/github.com/gorethink/gorethink#Term)\n\nSlice Expr Example\n```go\nr.Expr([]interface{}{1, 2, 3, 4, 5}).Run(session)\n```\nMap Expr Example\n```go\nr.Expr(map[string]interface{}{\"a\": 1, \"b\": 2, \"c\": 3}).Run(session)\n```\nGet Example\n```go\nr.DB(\"database\").Table(\"table\").Get(\"GUID\").Run(session)\n```\nMap Example (Func)\n```go\nr.Expr([]interface{}{1, 2, 3, 4, 5}).Map(func (row Term) interface{} {\n    return row.Add(1)\n}).Run(session)\n```\nMap Example (Implicit)\n```go\nr.Expr([]interface{}{1, 2, 3, 4, 5}).Map(r.Row.Add(1)).Run(session)\n```\nBetween (Optional Args) Example\n```go\nr.DB(\"database\").Table(\"table\").Between(1, 10, r.BetweenOpts{\n    Index: \"num\",\n    RightBound: \"closed\",\n}).Run(session)\n```\n\nFor any queries which use callbacks the function signature is important as your function needs to be a valid GoRethink callback, you can see an example of this in the map example above. The simplified explanation is that all arguments must be of type `r.Term`, this is because of how the query is sent to the database (your callback is not actually executed in your Go application but encoded as JSON and executed by RethinkDB). The return argument can be anything you want it to be (as long as it is a valid return value for the current query) so it usually makes sense to return `interface{}`. Here is an example of a callback for the conflict callback of an insert operation:\n\n```go\nr.Table(\"test\").Insert(doc, r.InsertOpts{\n    Conflict: func(id, oldDoc, newDoc r.Term) interface{} {\n        return newDoc.Merge(map[string]interface{}{\n            \"count\": oldDoc.Add(newDoc.Field(\"count\")),\n        })\n    },\n})\n```\n\n### Optional Arguments\n\nAs shown above in the Between example optional arguments are passed to the function as a struct. Each function that has optional arguments as a related struct. This structs are named in the format FunctionNameOpts, for example BetweenOpts is the related struct for Between.\n\n## Results\n\nDifferent result types are returned depending on what function is used to execute the query.\n\n- `Run` returns a cursor which can be used to view all rows returned.\n- `RunWrite` returns a WriteResponse and should be used for queries such as Insert, Update, etc...\n- `Exec` sends a query to the server and closes the connection immediately after reading the response from the database. If you do not wish to wait for the response then you can set the `NoReply` flag.\n\nExample:\n\n```go\nres, err := r.DB(\"database\").Table(\"tablename\").Get(key).Run(session)\nif err != nil {\n    // error\n}\ndefer res.Close() // Always ensure you close the cursor to ensure connections are not leaked\n```\n\nCursors have a number of methods available for accessing the query results\n\n- `Next` retrieves the next document from the result set, blocking if necessary.\n- `All` retrieves all documents from the result set into the provided slice.\n- `One` retrieves the first document from the result set.\n\nExamples:\n\n```go\nvar row interface{}\nfor res.Next(\u0026row) {\n    // Do something with row\n}\nif res.Err() != nil {\n    // error\n}\n```\n\n```go\nvar rows []interface{}\nerr := res.All(\u0026rows)\nif err != nil {\n    // error\n}\n```\n\n```go\nvar row interface{}\nerr := res.One(\u0026row)\nif err == r.ErrEmptyResult {\n    // row not found\n}\nif err != nil {\n    // error\n}\n```\n\n## Encoding/Decoding\nWhen passing structs to Expr(And functions that use Expr such as Insert, Update) the structs are encoded into a map before being sent to the server. Each exported field is added to the map unless\n\n  - the field's tag is \"-\", or\n  - the field is empty and its tag specifies the \"omitempty\" option.\n\nEach fields default name in the map is the field name but can be specified in the struct field's tag value. The \"gorethink\" key in\nthe struct field's tag value is the key name, followed by an optional comma\nand options. Examples:\n\n```go\n// Field is ignored by this package.\nField int `gorethink:\"-\"`\n// Field appears as key \"myName\".\nField int `gorethink:\"myName\"`\n// Field appears as key \"myName\" and\n// the field is omitted from the object if its value is empty,\n// as defined above.\nField int `gorethink:\"myName,omitempty\"`\n// Field appears as key \"Field\" (the default), but\n// the field is skipped if empty.\n// Note the leading comma.\nField int `gorethink:\",omitempty\"`\n// When the tag name includes an index expression\n// a compound field is created\nField1 int `gorethink:\"myName[0]\"`\nField2 int `gorethink:\"myName[1]\"`\n```\n\n**NOTE:** It is strongly recommended that struct tags are used to explicitly define the mapping between your Go type and how the data is stored by RethinkDB. This is especially important when using an `Id` field as by default RethinkDB will create a field named `id` as the primary key (note that the RethinkDB field is lowercase but the Go version starts with a capital letter).\n\nWhen encoding maps with non-string keys the key values are automatically converted to strings where possible, however it is recommended that you use strings where possible (for example `map[string]T`).\n\nIf you wish to use the `json` tags for GoRethink then you can call `SetTags(\"gorethink\", \"json\")` when starting your program, this will cause GoRethink to check for `json` tags after checking for `gorethink` tags. By default this feature is disabled. This function will also let you support any other tags, the driver will check for tags in the same order as the parameters.\n\n### Pseudo-types\n\nRethinkDB contains some special types which can be used to store special value types, currently supports are binary values, times and geometry data types. GoRethink supports these data types natively however there are some gotchas:\n - Time types: To store times in RethinkDB with GoRethink you must pass a `time.Time` value to your query, due to the way Go works type aliasing or embedding is not support here\n - Binary types: To store binary data pass a byte slice (`[]byte`) to your query\n - Geometry types: As Go does not include any built-in data structures for storing geometry data GoRethink includes its own in the `github.com/gorethink/gorethink/types` package, Any of the types (`Geometry`, `Point`, `Line` and `Lines`) can be passed to a query to create a RethinkDB geometry type.\n\n### Compound Keys\n\nRethinkDB unfortunately does not support compound primary keys using multiple fields however it does support compound keys using an array of values. For example if you wanted to create a compound key for a book where the key contained the author ID and book name then the ID might look like this `[\"author_id\", \"book name\"]`. Luckily GoRethink allows you to easily manage these keys while keeping the fields separate in your structs. For example:\n\n```go\ntype Book struct {\n  AuthorID string `gorethink:\"id[0]\"`\n  Name     string `gorethink:\"id[1]\"`\n}\n// Creates the following document in RethinkDB\n{\"id\": [AUTHORID, NAME]}\n```\n\n### References\n\nSometimes you may want to use a Go struct that references a document in another table, instead of creating a new struct which is just used when writing to RethinkDB you can annotate your struct with the reference tag option. This will tell GoRethink that when encoding your data it should \"pluck\" the ID field from the nested document and use that instead.\n\nThis is all quite complicated so hopefully this example should help. First lets assume you have two types `Author` and `Book` and you want to insert a new book into your database however you dont want to include the entire author struct in the books table. As you can see the `Author` field in the `Book` struct has some extra tags, firstly we have added the `reference` tag option which tells GoRethink to pluck a field from the `Author` struct instead of inserting the whole author document. We also have the `gorethink_ref` tag which tells GoRethink to look for the `id` field in the `Author` document, without this tag GoRethink would instead look for the `author_id` field.\n\n```go\ntype Author struct {\n    ID      string  `gorethink:\"id,omitempty\"`\n    Name    string  `gorethink:\"name\"`\n}\n\ntype Book struct {\n    ID      string  `gorethink:\"id,omitempty\"`\n    Title   string  `gorethink:\"title\"`\n    Author  Author `gorethink:\"author_id,reference\" gorethink_ref:\"id\"`\n}\n```\n\nThe resulting data in RethinkDB should look something like this:\n\n```json\n{\n    \"author_id\": \"author_1\",\n    \"id\":  \"book_1\",\n    \"title\":  \"The Hobbit\"\n}\n```\n\nIf you wanted to read back the book with the author included then you could run the following GoRethink query:\n\n```go\nr.Table(\"books\").Get(\"1\").Merge(func(p r.Term) interface{} {\n    return map[string]interface{}{\n        \"author_id\": r.Table(\"authors\").Get(p.Field(\"author_id\")),\n    }\n}).Run(session)\n```\n\nYou are also able to reference an array of documents, for example if each book stored multiple authors you could do the following:\n\n```go\ntype Book struct {\n    ID       string  `gorethink:\"id,omitempty\"`\n    Title    string  `gorethink:\"title\"`\n    Authors  []Author `gorethink:\"author_ids,reference\" gorethink_ref:\"id\"`\n}\n```\n\n```json\n{\n    \"author_ids\": [\"author_1\", \"author_2\"],\n    \"id\":  \"book_1\",\n    \"title\":  \"The Hobbit\"\n}\n```\n\nThe query for reading the data back is slightly more complicated but is very similar:\n\n```go\nr.Table(\"books\").Get(\"book_1\").Merge(func(p r.Term) interface{} {\n    return map[string]interface{}{\n        \"author_ids\": r.Table(\"authors\").GetAll(r.Args(p.Field(\"author_ids\"))).CoerceTo(\"array\"),\n    }\n})\n```\n\n### Custom `Marshaler`s/`Unmarshaler`s\n\nSometimes the default behaviour for converting Go types to and from ReQL is not desired, for these situations the driver allows you to implement both the [`Marshaler`](https://godoc.org/github.com/gorethink/gorethink/encoding#Marshaler) and [`Unmarshaler`](https://godoc.org/github.com/gorethink/gorethink/encoding#Unmarshaler) interfaces. These interfaces might look familiar if you are using to using the `encoding/json` package however instead of dealing with `[]byte` the interfaces deal with `interface{}` values (which are later encoded by the `encoding/json` package when communicating with the database).\n\nAn good example of how to use these interfaces is in the [`types`](https://github.com/gorethink/gorethink/blob/master/types/geometry.go#L84-L106) package, in this package the `Point` type is encoded as the `GEOMETRY` pseudo-type instead of a normal JSON object.\n\n## Logging\n\nBy default the driver logs are disabled however when enabled the driver will log errors when it fails to connect to the database. If you would like more verbose error logging you can call `r.SetVerbose(true)`.\n\nAlternatively if you wish to modify the logging behaviour you can modify the logger provided by `github.com/Sirupsen/logrus`. For example the following code completely disable the logger:\n\n```go\n// Enabled\nr.Log.Out = os.Stderr\n// Disabled\nr.Log.Out = ioutil.Discard\n```\n\n## Mocking\n\nThe driver includes the ability to mock queries meaning that you can test your code without needing to talk to a real RethinkDB cluster, this is perfect for ensuring that your application has high unit test coverage.\n\nTo write tests with mocking you should create an instance of `Mock` and then setup expectations using `On` and `Return`. Expectations allow you to define what results should be returned when a known query is executed, they are configured by passing the query term you want to mock to `On` and then the response and error to `Return`, if a non-nil error is passed to `Return` then any time that query is executed the error will be returned, if no error is passed then a cursor will be built using the value passed to `Return`. Once all your expectations have been created you should then execute you queries using the `Mock` instead of a `Session`.\n\nHere is an example that shows how to mock a query that returns multiple rows and the resulting cursor can be used as normal.\n\n```go\nfunc TestSomething(t *testing.T) {\n    mock := r.NewMock()\n    mock.on(r.Table(\"people\")).Return([]interface{}{\n        map[string]interface{}{\"id\": 1, \"name\": \"John Smith\"},\n        map[string]interface{}{\"id\": 2, \"name\": \"Jane Smith\"},\n    }, nil)\n\n    cursor, err := r.Table(\"people\").Run(mock)\n    if err != nil {\n        t.Errorf(err)\n    }\n\n    var rows []interface{}\n    err := res.All(\u0026rows)\n    if err != nil {\n        t.Errorf(err)\n    }\n\n    // Test result of rows\n\n    mock.AssertExpectations(t)\n}\n```\n\nThe mocking implementation is based on amazing https://github.com/stretchr/testify library, thanks to @stretchr for their awesome work!\n\n## Benchmarks\n\nEveryone wants their project's benchmarks to be speedy. And while we know that rethinkDb and the gorethink driver are quite fast, our primary goal is for our benchmarks to be correct. They are designed to give you, the user, an accurate picture of writes per second (w/s). If you come up with a accurate test that meets this aim, submit a pull request please.\n\nThanks to @jaredfolkins for the contribution.\n\n| Type    |  Value   |\n| --- | --- |\n| **Model Name** | MacBook Pro |\n| **Model Identifier** | MacBookPro11,3 |\n| **Processor Name** | Intel Core i7 |\n| **Processor Speed** | 2.3 GHz |\n| **Number of Processors** | 1 |\n| **Total Number of Cores** | 4 |\n| **L2 Cache (per Core)** | 256 KB |\n| **L3 Cache** | 6 MB |\n| **Memory** | 16 GB |\n\n```bash\nBenchmarkBatch200RandomWrites                20                              557227775                     ns/op\nBenchmarkBatch200RandomWritesParallel10      30                              354465417                     ns/op\nBenchmarkBatch200SoftRandomWritesParallel10  100                             761639276                     ns/op\nBenchmarkRandomWrites                        100                             10456580                      ns/op\nBenchmarkRandomWritesParallel10              1000                            1614175                       ns/op\nBenchmarkRandomSoftWrites                    3000                            589660                        ns/op\nBenchmarkRandomSoftWritesParallel10          10000                           247588                        ns/op\nBenchmarkSequentialWrites                    50                              24408285                      ns/op\nBenchmarkSequentialWritesParallel10          1000                            1755373                       ns/op\nBenchmarkSequentialSoftWrites                3000                            631211                        ns/op\nBenchmarkSequentialSoftWritesParallel10      10000                           263481                        ns/op\n```\n\n## Examples\n\nMany functions have examples and are viewable in the godoc, alternatively view some more full features examples on the [wiki](https://github.com/gorethink/gorethink/wiki/Examples).\n\nAnother good place to find examples are the tests, almost every term will have a couple of tests that demonstrate how they can be used.\n\n## Further reading\n\n- [GoRethink Goes 1.0](https://www.compose.io/articles/gorethink-goes-1-0/)\n- [Go, RethinkDB \u0026 Changefeeds](https://www.compose.io/articles/go-rethinkdb-and-changefeeds-part-1/)\n- [Build an IRC bot in Go with RethinkDB changefeeds](http://rethinkdb.com/blog/go-irc-bot/)\n\n## License\n\nCopyright 2013 Daniel Cannon\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n## Donations\n\n[![Donations](https://pledgie.com/campaigns/29517.png \"Donations\")](https://pledgie.com/campaigns/29517)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funloop%2Fgorethink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funloop%2Fgorethink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funloop%2Fgorethink/lists"}