Struct mongo_driver::database::Database
[−]
[src]
pub struct Database<'a> { /* fields omitted */ }
Provides access to a MongoDB database.
A database instance can be created by calling get_database
or take_database
on a Client
instance.
Methods
impl<'a> Database<'a>
[src]
pub fn new(
created_by: CreatedBy<'a>,
inner: *mut mongoc_database_t
) -> Database<'a>
[src]
created_by: CreatedBy<'a>,
inner: *mut mongoc_database_t
) -> Database<'a>
pub fn command(
&'a self,
command: Document,
options: Option<&CommandAndFindOptions>
) -> Result<Cursor<'a>>
[src]
&'a self,
command: Document,
options: Option<&CommandAndFindOptions>
) -> Result<Cursor<'a>>
Execute a command on the database.
This is performed lazily and therefore requires calling next
on the resulting cursor.
if your are using a command like find or aggregate command_batch
is likely
more convenient for you.
pub fn command_batch(
&'a self,
command: Document,
options: Option<&CommandAndFindOptions>
) -> Result<BatchCursor<'a>>
[src]
&'a self,
command: Document,
options: Option<&CommandAndFindOptions>
) -> Result<BatchCursor<'a>>
Execute a command on the database and returns a BatchCursor
Automates the process of getting the next batch from getMore
and parses the batch so only the result documents are returned.
I am unsure of the best practices of when to use this or the CRUD function.
pub fn command_simple(
&'a self,
command: Document,
read_prefs: Option<&ReadPrefs>
) -> Result<Document>
[src]
&'a self,
command: Document,
read_prefs: Option<&ReadPrefs>
) -> Result<Document>
Simplified version of command
that returns the first document immediately.
pub fn create_collection<S: Into<Vec<u8>>>(
&self,
name: S,
options: Option<&Document>
) -> Result<Collection>
[src]
&self,
name: S,
options: Option<&Document>
) -> Result<Collection>
Create a new collection in this database.
pub fn get_collection<S: Into<Vec<u8>>>(&self, collection: S) -> Collection
[src]
Borrow a collection
pub fn take_collection<S: Into<Vec<u8>>>(self, collection: S) -> Collection<'a>
[src]
Take a collection, database is owned by the collection so the collection can easily be passed around
pub fn get_name(&self) -> Cow<str>
[src]
Get the name of this database.
pub fn has_collection<S: Into<Vec<u8>>>(&self, name: S) -> Result<bool>
[src]
This function checks to see if a collection exists on the MongoDB server within database.