h2co3 / avocado Goto Github PK
View Code? Open in Web Editor NEWStrongly-typed MongoDB driver for Rust
License: MIT License
Strongly-typed MongoDB driver for Rust
License: MIT License
Here is related question: #4
Now we can't redefine some Doc's methods if we use proc macro on structure.
Hello, the crate is amazing but the docs are missing somewhere.
For example, I have a vector of struct which implements Doc
. Now I want to upsert_many
: insert if does not exist and update content if exists.
Should I really need to create another struct-operation, implement Upsert
trait for it and use it for this operation? Maybe there is a simple way for this?
Hey ho! :)
It works, but now we don't have info about inserted_ids when ordered = false.
Lines 149 to 157 in e430353
So you check result and if there were bulk error, drop the request as failed. But InsertManyResult also contains info about inserted ids:
pub struct InsertManyResult {
pub acknowledged: bool,
pub inserted_ids: Option<BTreeMap<i64, Bson>>,
pub bulk_write_exception: Option<BulkWriteException>,
}
And I can't understand in code that transaction is okay and how many rows were anyway inserted because of ordered = false.
I'm not sure what's the correct way to handle such situation. Maybe when ordered=false in insert many, don't return Err
if result was BulkWriteException
and mark it always as success?
Is it possible to write statically typed filters? (e.g. similar to what diesel
has or something else), and if not, is there any plans for them?
Something like:
#[derive(Debug, Serialize, Deserialize, Doc, Clone)]
pub struct Example {
#[serde(rename = "_id")]
pub id: Uid<Example>,
pub description: String,
}
...
let example_col: Collection<Example> = shared.db.existing_collection();
let res: Example = example_col.find_one(Example::description.eq("abc"));
Hello, there is no way to specify for insert_many
ordered option: https://docs.rs/mongodb/0.3.12/mongodb/coll/options/struct.InsertManyOptions.html#structfield.ordered
It's useful, when we insert vector of data and some fields could fail on insert (for example, because of unique index). When we set ordered to false, mongodb will ignore errors and try to insert as much as possible.
Hi! Thanks again for amazing wrapper :)
I found, that it's not possible to derive Doc
for generic structure:
> message: `Doc` can't be derived for a type that is generic over type parameters
#[derive(Doc, Serialize, Deserialize)]
pub struct Test<T: Serialize + Deserialize> {
pub data<T>
}
We specify Output
type for queries, maybe we also can specify somehow exact types for deserialization?
With the (alpha) release of the actually-official MongoDB Rust driver, will we see Avocado updated to support it?
Thanks for amazing library @H2CO3 Would it be possible to do changelog in github releases?
Hi! I found that in Query
trait method options (https://docs.rs/avocado/0.3.3/avocado/ops/trait.Query.html#method.options) is static method (does not have access to data).
It's useful to access some inner data to configure, for example, count
and limit
. I need this for pagination query where that params are dynamic for options but the same for filtering.
The "fuck counter" and the "goto counter" (does that one even make sense in Rust?) both show 1, but the only result is their entry in the README...
And the "unsafe counter" shows three, but the results are (again) the counter in the README, and then the #![deny(...)]
entries which should make it impossible to have unsafe code...
I don't know if this is intentional, but it sounds like the counters don't really make sense. Just wanted to let you know :)
There doesn't seem to be a feature or any documentation for SSL connections. Is that by design or does SSL just work if you need to use it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.