An ODM for MongoDB built on the official MongoDB Rust driver.
Now that Model::sync
index management is back, we are finally ready to release an official 0.9.0
. All of the changes released so far as part of the various 0.9.0-alpha.*
releases are included as part of this release. Big shoutout to @simoneromano96 for all of their hard work on the updates to Model::sync
, thank you!
Model::sync
is back! This has taken much longer than intended, but it is finally back. It also has a few improvements where index options are diffed in order to ensure that subtle updates to an index are observed and indexes are re-created as needed. This closes #51.delete_many
method.No significant changes, just matching the upcoming Wither 0.9.0 release.
async_trait::async_trait
macro as a pub export of the wither
crate, so that code generated from wither_derive
can use #[wither::async_trait]
instead of requiring users to declare async-trait
as a dependency. This seems like the right thing to do here ... we'll see. If this causes problems for you (which it shouldn't), please open an issue.For those new to this project, Wither is an ODM for MongoDB built on the official MongoDB Rust driver. This is an alpha release for 0.9.0
, and is overall shaping up to be an excellent release.
A major highlight, everything is async now! This is squarely due to the mongodb team's recent 1.0 release of the driver, which supports both tokio & async-std runtimes. Wither directly reaps the benefits of these updates, so big thanks to the MongoDB team.
Lots of other good stuff here, read on to learn more.
async
. All synchronous code has been disabled, and will be removed from the tree soon.Model::read_concern
, Model::write_concern
& Model::selection_criteria
match the driver's updated mechanism for specifying these values. They may all be derived, and are always used via Model::collection
and any of the model methods which interact with a model's collection.ModelCursor
type which wraps a cursor and yields model instances.[email protected]
and is now a public export of this crate.[email protected]
and is now a public export of this crate.DeserializeOwned
, instead of Deserialize
. This simplifies some aspects of the Model
trait.Model
methods which interact with the collection have been updated to match the driver's new collection interface. Lots of good stuff here. Check out the docs.Index management has not yet been implemented in the mongodb driver as of 1.0
, and thus the index syncing features of Model::sync
have been temporarily disabled. The hope is that the mongodb team will be able to land their index management code in the driver soon, at which point we will re-enable the Model::sync
functionality.
If this is important to you, please head over to wither#51 and let us know!
Notwithstanding, there are a few other changes to note:
wither::IndexModel
struct as a placeholder. This allows our Model
interface to stay mostly the same, and allows us to preserve our index derivations using the #[derive(Model)]
system.Model::sync
is still present and callable, but has been temporarily deprecated until we are able to figure out the index management story. I mostly chose to use the deprecation pattern, even if a bit inaccurate, because it guarantees that folks will have a compiler warning letting them know that the functionality has been temporarily disabled.The model derivation system has been GREATLY improved. The entire crate has been refactored. The code should be much more approachable to new folks wanting to contribute, and should be easier to maintain going forward.
proc-macro-error
and are fully spanned (which means any attribute errors related to the derive system will be highlighted with pin-point accuracy at compile time).dtolnay
's excellent trybuild for testing the compilation of our derive system. Big win here.keys
field and an options
field (which is optional). Both are expected to be quoted doc!{...}
invocations. See the docs for more details.Index management :'(
... though this should only be temporary.
The core wither
crate is 100% backwards compatible with this release, but the Model
trait has received a few additional methods. Namely the find_one_and_(delete|replace|update)
methods. Came across a use case where I needed them and then realized that I never implemented them. Now they are here. Woot woot!
The wither_derive
crate has received a few backwards incompatible changes. The motivation behind doing this is detailed in #21. The main issue is that we need the derive system to be abstract enough to deal with embedded documents. The backwards incompatible changes are here.
#[model(index())]
, the index_type
attr has been reduced to simply be index
. All of the same rules apply as before. This change was made for ergonomic reasons. Less typing. Easier to follow.#[model(index())]
, the with(...)
attr has been updated to support subdocuments. The new syntax for this attr is with(field="...", index="...")
. Supply a with(...)
attr for each independent field to include.#[model(index())]
, the weights(...)
attr has been updated for the same reason as with
. Now, you need to supply one weight(field="...", weight="...")
per field weight you are specifying.The only net-new item being added here is that now, within #[model(index())]
, you can use the attr embedded="..."
to cause the index declaration to apply to the embedded document/field specified. See the docs for more details.
It is my sincere hope that this is the last breaking change I will need to make to this crate before promoting this crate to a 1.0.0
release. Let's hope! Please let me know if there are any issues you have with these updates.
Just adding this tag/release. The crates.io release has been out for a good amount of time now.