-
Type: Task
-
Resolution: Works as Designed
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:
I run into a bug because I through my sort was working but it wasn't because my data was already sorted, I miss spell the field I wanted to sort. And worse as I implement sort by hand because `allow_disk_use` option with `find()` is too recent for my mongodb version, (but current sort option on find I would need to implement it by hand too) I miss up 1 and -1 on my enum...
So is there a way to make mongodb report me an error if I try to sort on document that doesn't have this field ? I search a lot I didn't find much.
And second question would it make sense to maintain enum on mongodb side for Asc and Desc sorting integer:
Unable to find source-code formatter for language: rust. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
#[derive(Debug, Clone, Copy, PartialEq)] #[repr(i8)] pub enum SortKind { Ascending = 1, Descending = -1, } impl From<SortKind> for bson::Bson { fn from(sort_kind: SortKind) -> Self { bson::Bson::I32(sort_kind as i32) } }
or use https://crates.io/crates/serde_repr.
My current code is:
Unable to find source-code formatter for language: rust. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
let packets_raw = self.client.database(Self::BLENDER) .collection(Self::PACKETS_RAW); let option = AggregateOptions::builder() .allow_disk_use(true) .build(); let mut timestamp = bson::Document::new(); timestamp.insert("timestamp", SortKind::Ascending); let mut sort = bson::Document::new(); sort.insert("$sort", timestamp); let mut packets_raw = packets_raw.aggregate(Some(sort), option) .await .context(MongoDB {})?;
Off topic: Please let's use github issue...