[−][src]Struct couchbase::Cluster
Connect to a Couchbase cluster and perform cluster-level operations
This Cluster
object is also your main and only entry point into the SDK.
Implementations
impl Cluster
[src]
pub fn connect<S: Into<String>>(
connection_string: S,
username: S,
password: S
) -> Self
[src]
connection_string: S,
username: S,
password: S
) -> Self
Connect to a couchbase cluster
Arguments
connection_string
- the connection string containing the bootstrap hostsusername
- the name of the user, used for authenticationpassword
- the password of the user
Examples
Connecting to localhost with the username
and its password
.
let cluster = Cluster::connect("127.0.0.1", "username", "password");
Using three nodes for bootstrapping (recommended for production):
let cluster = Cluster::connect("couchbase://hosta,hostb,hostc", "username", "password");
pub fn bucket<S: Into<String>>(&self, name: S) -> Bucket
[src]
Open and connect to a couchbase Bucket
Arguments
name
- the name of the bucket
Examples
Connect and open the travel-sample
bucket.
let cluster = Cluster::connect("127.0.0.1", "username", "password"); let bucket = cluster.bucket("travel-sample");
pub async fn query<S: Into<String>, '_>(
&'_ self,
statement: S,
options: QueryOptions
) -> CouchbaseResult<QueryResult>
[src]
&'_ self,
statement: S,
options: QueryOptions
) -> CouchbaseResult<QueryResult>
Executes a N1QL statement
Arguments
statement
- the N1QL statement to executeoptions
- allows to pass in custom options
Examples
Run a N1QL query with default options.
let result = cluster.query("select * from bucket", QueryOptions::default());
This will return an async result, which can be consumed:
match cluster.query("select 1=1", QueryOptions::default()).await { Ok(mut result) => { for row in result.rows::<serde_json::Value>().next().await { println!("Found Row {:?}", row); } }, Err(e) => panic!("Query failed: {:?}", e), }
See the QueryResult for more information on what and how it can be consumed.
pub async fn analytics_query<S: Into<String>, '_>(
&'_ self,
statement: S,
options: AnalyticsOptions
) -> CouchbaseResult<AnalyticsResult>
[src]
&'_ self,
statement: S,
options: AnalyticsOptions
) -> CouchbaseResult<AnalyticsResult>
Executes an analytics query
Arguments
statement
- the analyticss statement to executeoptions
- allows to pass in custom options
Examples
Run an analytics query with default options.
let result = cluster.analytics_query("select * from dataset", AnalyticsOptions::default());
This will return an async result, which can be consumed:
match cluster.query("select 1=1", AnalyticsOptions::default()).await { Ok(mut result) => { for row in result.rows::<serde_json::Value>().next().await { println!("Found Row {:?}", row); } }, Err(e) => panic!("Query failed: {:?}", e), }
See the AnalyticsResult for more information on what and how it can be consumed.
pub async fn search_query<S: Into<String>, T: SearchQuery, '_>(
&'_ self,
index: S,
query: T,
options: SearchOptions
) -> CouchbaseResult<SearchResult>
[src]
&'_ self,
index: S,
query: T,
options: SearchOptions
) -> CouchbaseResult<SearchResult>
Executes a search query
Arguments
index
- the search index name to usequery
- the search query to performoptions
- allows to pass in custom options
Examples
Run a search query with default options.
let result = cluster.search_query( String::from("test"), QueryStringQuery::new(String::from("swanky")), SearchOptions::default(), );
This will return an async result, which can be consumed:
match cluster.cluster.search_query( String::from("test"), QueryStringQuery::new(String::from("swanky")), SearchOptions::default(), ).await { Ok(mut result) => { for row in result.rows::<serde_json::Value>().next().await { println!("Found Row {:?}", row); } }, Err(e) => panic!("Query failed: {:?}", e), }
See the SearchResult for more information on what and how it can be consumed.
pub fn users(&self) -> UserManager
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl !UnwindSafe for Cluster
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,