Struct bonsaidb_core::schema::List
source · pub struct List<'a, Cn, Cl, PrimaryKey>(_)
where
Cl: Collection,
PrimaryKey: KeyEncoding<Cl::PrimaryKey> + PartialEq + ?Sized,
Cl::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>;
Expand description
Retrieves a list of documents from a collection. This structure also offers functions to customize the options for the operation.
Implementations§
source§impl<'a, Cn, Cl, PrimaryKey> List<'a, Cn, Cl, PrimaryKey>where
Cl: SerializedCollection,
Cn: Connection,
PrimaryKey: KeyEncoding<Cl::PrimaryKey> + PartialEq + ?Sized + 'a,
Cl::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,
impl<'a, Cn, Cl, PrimaryKey> List<'a, Cn, Cl, PrimaryKey>where Cl: SerializedCollection, Cn: Connection, PrimaryKey: KeyEncoding<Cl::PrimaryKey> + PartialEq + ?Sized + 'a, Cl::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,
sourcepub fn descending(self) -> Self
pub fn descending(self) -> Self
Lists documents by id in descending order.
sourcepub fn headers(self) -> Result<Vec<Header>, Error>
pub fn headers(self) -> Result<Vec<Header>, Error>
Returns the list of document headers contained within the range.
println!(
"Headers with id 42 or larger: {:?}",
MyCollection::list(42.., db).headers()?
);
println!(
"Headers in MyCollection: {:?}",
MyCollection::all(db).headers()?
);
sourcepub fn count(self) -> Result<u64, Error>
pub fn count(self) -> Result<u64, Error>
Returns the number of documents contained within the range.
Order and limit are ignored if they were set.
println!(
"Number of documents with id 42 or larger: {}",
MyCollection::list(42.., db).count()?
);
println!(
"Number of documents in MyCollection: {}",
MyCollection::all(db).count()?
);