Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 1503946

Browse files
committed
Merge pull request #116 from kyeah/1.0
Use create option for Collection::new
2 parents 9d997cb + cc24f7b commit 1503946

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/coll/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ impl Collection {
3535
/// Creates a collection representation with optional read and write controls.
3636
///
3737
/// If `create` is specified, the collection will be explicitly created in the database.
38-
pub fn new(db: Database, name: &str, _create: bool,
38+
pub fn new(db: Database, name: &str, create: bool,
3939
read_preference: Option<ReadPreference>,
4040
write_concern: Option<WriteConcern>) -> Collection {
4141

4242
let rp = read_preference.unwrap_or(db.read_preference.to_owned());
4343
let wc = write_concern.unwrap_or(db.write_concern.to_owned());
4444

45+
if create {
46+
// Attempt to create the collection explicitly, or fail silently.
47+
let _ = db.create_collection(name, None);
48+
}
49+
4550
Collection {
4651
db: db.clone(),
4752
namespace: format!("{}.{}", db.name, name),

0 commit comments

Comments
 (0)