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
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! Rust ReQL command reference
//!
//! Submit issues and pull requests to our [Github
//! repository](https://github.com/rust-rethinkdb/reql).
//!
//! # Accessing ReQL
//!
//! Import this crate and bring the prelude into scope:-
//!
//! ```norun
//! extern crate reql;
//!
//! use reql::prelude::*;
//! ```
//!
//! ## r
//!
//! > r -> r
//!
//! The top-level ReQL namespace.
//!
//! ### Examples
//!
//! Setup your top-level namespace.
//!
//! ```norun
//! use reql::r;
//! ```
//!
//! [Read more about this command →](constant.r.html)
//!
//! ----------
//!
//! ## connection
//!
//! > r.connection() → builder
//!
//! Create a new connection to the database server. `connection()` returns a builder object with the
//! following methods:
//!
//! - `set_servers()`: the servers to connect to (default `vec!["localhost:28015"]`).
//! - `set_db()`: the default database (default `"test"`).
//! - `set_user()`: the user account to connect as (default `"admin"`).
//! - `set_password()`: the password for the user (default `""`).
//! - `set_retries()`: the number of times to retry a failed command (default `5`).
//! - `connect()`: create a connection pool and connect to all servers with the parameters previously
//! passed to the builder.
//!
//! If the connection cannot be established, an `Error::Driver` will be returned.
//!
//! ### Examples
//!
//! Open a connection using the default host and port, specifying the default database.
//!
//! ```norun
//! r.connection().connect().expect("Failed to connect to the database server");
//! ```
//!
//! [Read more about this command →](command/struct.ConnectOpts.html#method.connect)
//!
//! ----------
//!
//! ## run
//!
//! > query.run() -> stream result
//!
//! Run a query returning a [futures stream receiver].
//!
//! [futures stream receiver]: https://docs.rs/futures/*/futures/stream/struct.Receiver.html
//!
//! ### Examples
//!
//! ```norun
//! let users = try!(r.table("users").run::<User>());
//! let response = users.for_each(|user| {
//!     println!("{:?}", user);
//!     Ok(())
//! });
//! response.wait();
//! ```
//!
//! [Read more about this command →](command/struct.Command.html#method.run)
//!
//! ----------
//!
//! ## run_with_opts
//!
//! > query.run_with_opts(options) -> stream result
//!
//! Run a query specifying certain options and returning a [futures stream receiver].
//!
//! [futures stream receiver]: https://docs.rs/futures/*/futures/stream/struct.Receiver.html
//!
//! ### Examples
//!
//! ```norun
//! let options = r.object()
//!     .insert("profile", true)
//!     .build();
//! let users = try!(r.table("users").run_with_opts::<User>(options));
//! let response = users.for_each(|user| {
//!     println!("{:?}", user);
//!     Ok(())
//! });
//! response.wait();
//! ```
//!
//! [Read more about this command →](command/struct.Command.html#method.run_with_opts)
//!
//! ----------

extern crate ql2;
extern crate r2d2;
extern crate serde;
extern crate serde_json;
extern crate byteorder;
extern crate bufstream;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate slog;
#[macro_use]
extern crate quick_error;
extern crate slog_term;
extern crate protobuf;
extern crate scram;
extern crate parking_lot;
extern crate uuid;
extern crate futures;

pub mod prelude;
pub mod command;
pub mod error;

/// The top-level ReQL namespace
#[allow(non_upper_case_globals)]
pub const r: command::Client = command::Client;