|
|
|
@ -129,8 +129,9 @@ impl<'a> Collection<'a> {
|
|
|
|
|
|
|
|
|
|
let default_options = CommandAndFindOptions::default();
|
|
|
|
|
let options = options.unwrap_or(&default_options);
|
|
|
|
|
let fields_bsonc = options.fields_bsonc();
|
|
|
|
|
|
|
|
|
|
let inner = unsafe {
|
|
|
|
|
let cursor_ptr = unsafe {
|
|
|
|
|
bindings::mongoc_collection_command(
|
|
|
|
|
self.inner,
|
|
|
|
|
options.query_flags.flags(),
|
|
|
|
@ -138,10 +139,8 @@ impl<'a> Collection<'a> {
|
|
|
|
|
options.limit,
|
|
|
|
|
options.batch_size,
|
|
|
|
|
try!(Bsonc::from_document(&command)).inner(),
|
|
|
|
|
match options.fields {
|
|
|
|
|
Some(ref f) => {
|
|
|
|
|
try!(Bsonc::from_document(f)).inner()
|
|
|
|
|
},
|
|
|
|
|
match fields_bsonc {
|
|
|
|
|
Some(ref f) => f.inner(),
|
|
|
|
|
None => ptr::null()
|
|
|
|
|
},
|
|
|
|
|
match options.read_prefs {
|
|
|
|
@ -151,11 +150,15 @@ impl<'a> Collection<'a> {
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if inner.is_null() {
|
|
|
|
|
if cursor_ptr.is_null() {
|
|
|
|
|
return Err(InvalidParamsError.into())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(Cursor::new(cursor::CreatedBy::Collection(self), inner))
|
|
|
|
|
Ok(Cursor::new(
|
|
|
|
|
cursor::CreatedBy::Collection(self),
|
|
|
|
|
cursor_ptr,
|
|
|
|
|
fields_bsonc
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn count(
|
|
|
|
@ -240,8 +243,9 @@ impl<'a> Collection<'a> {
|
|
|
|
|
|
|
|
|
|
let default_options = CommandAndFindOptions::default();
|
|
|
|
|
let options = options.unwrap_or(&default_options);
|
|
|
|
|
let fields_bsonc = options.fields_bsonc();
|
|
|
|
|
|
|
|
|
|
let inner = unsafe {
|
|
|
|
|
let cursor_ptr = unsafe {
|
|
|
|
|
bindings::mongoc_collection_find(
|
|
|
|
|
self.inner,
|
|
|
|
|
options.query_flags.flags(),
|
|
|
|
@ -249,10 +253,8 @@ impl<'a> Collection<'a> {
|
|
|
|
|
options.limit,
|
|
|
|
|
options.batch_size,
|
|
|
|
|
try!(Bsonc::from_document(query)).inner(),
|
|
|
|
|
match options.fields {
|
|
|
|
|
Some(ref f) => {
|
|
|
|
|
try!(Bsonc::from_document(f)).inner()
|
|
|
|
|
},
|
|
|
|
|
match fields_bsonc {
|
|
|
|
|
Some(ref f) => f.inner(),
|
|
|
|
|
None => ptr::null()
|
|
|
|
|
},
|
|
|
|
|
match options.read_prefs {
|
|
|
|
@ -262,11 +264,15 @@ impl<'a> Collection<'a> {
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if inner.is_null() {
|
|
|
|
|
if cursor_ptr.is_null() {
|
|
|
|
|
return Err(InvalidParamsError.into())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(Cursor::new(cursor::CreatedBy::Collection(self), inner))
|
|
|
|
|
Ok(Cursor::new(
|
|
|
|
|
cursor::CreatedBy::Collection(self),
|
|
|
|
|
cursor_ptr,
|
|
|
|
|
fields_bsonc
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn get_name(&self) -> Cow<str> {
|
|
|
|
|