15 releases (6 breaking)

0.6.0 Jul 7, 2019
0.4.0 Jun 19, 2019
0.3.3 Mar 16, 2019
0.0.5 Dec 15, 2018
0.0.1 Jul 18, 2018

#2833 in Database interfaces

Download history 9/week @ 2024-03-30 3/week @ 2024-04-06

54 downloads per month

MIT license

135KB
2K SLoC

Avocado, the strongly-typed MongoDB driver

Avocado on crates.io Avocado on docs.rs rustc Avocado Download Avocado License Lines of Code Twitter

goto counter unsafe counter fuck counter

Usage

  • See the online documentation above, or open it locally:

  • cargo doc --open

  • Check out the examples/ folder

  • More high-level information can be found on the project page.

  • The schema_validation feature can be enabled (it's enabled by default), in which case the DatabaseExt::empty_collection() method becomes available. If a collection is created using this method, it will add a JSON schema validation pass and specify the schema as generated by magnet.

  • The raw_uuid feature (also enabled by default) adds some useful extension methods to make it more convenient to work with UUIDs as the type of the _id field.

    This can potentially be slow if you are performing many insertions into a collection of a complex type. However, it dynamically ensures that other users/drivers can't put malformed data in the collection. Therefore it's probably more useful if you or somebody else are accessing a database from outside the Avocado driver too. It's also great for debugging Avocado itself.

Changelog

v0.6.0

  • Fix #6 by adding a context dictionary to Error.

v0.5.0

  • Fix #5 by adding an #[options(...)] attribute to the Doc derive proc-macro.

v0.4.0

  • Fix #2 by adding a &self parameter to the options() methods on ops:: traits.

v0.3.3

  • Fix a deprecation warning related to Uuid::from_random_bytes()
  • Catch some errors that incorrectly pass through the MongoDB client's Cursor API

v0.3.2

  • Added a remove_inner_doc() method to DocumentExt. This allows for the easy chaining of removal from hierarchically contained Documents in transform().
  • Fixed a bug where inserting 0 entities into a collection failed.
  • Fixed the incorrect ordering of the key and the value type in the error message generated by DocumentExt::remove_*() methods.

v0.3.1

  • Added a DocumentExt trait to the prelude for convenient and idiomatic implementation of transform(raw: Document) -> Result<Bson> methods
  • Hopefully fixed the code so that docs.rs can handle it now

v0.3.0

  • Added Doc::id() and Doc::set_id() methods for the sake of better efficiency in some Collection methods
    • This means that single-element wrappers such as Box<Doc> and RefCell<Doc> can no longer implement Doc themselves
  • Added Collection::find_one_and_delete(), Collection::find_one_and_replace(), and Collection::find_one_and_update() methods
  • Added more documentation and clarified/improved existing docs
  • Added more tests, including compile-time tests for cases when #[derive(Doc)] should fail, as well as testing that an optional _id is correctly allowed

Compile-time testing the derive macro

Due to a bug in compiletest_rs, running the tests that check the error messages of the #[derive(Doc)] proc-macro requires running cargo clean first, otherwise compilation will fail with E0464.

Therefore, the recommended way of running the tests is:

cargo clean && cargo test

TODO:

  • Add weights property to text indices
  • Add migrations
  • Default Doc::Id to ObjectId and Query::Output and FindAndUpdate::Output to T, once #29661 is stabilized

Dependencies

~16MB
~315K SLoC