Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Spark-ORM: MongoDB ORM for Rust
Spark-ORM is a high-performance, open-source Object-Relational Mapping (ORM) library designed specifically for MongoDB in Rust. It seamlessly bridges Rust structs with MongoDB collections, effortlessly converting structs into models.
Features
-
Derive Models: Effortlessly convert Rust structs into MongoDB models using the
Model
trait derivation. -
Custom Collection Names: Tailor collection names for your models with the
#[coll_name]
attribute. -
Memory Efficiency: Built for speed and memory efficiency, Spark-ORM offers a non-heap copy ORM solution for MongoDB.
Getting Started
-
Define your model by simply applying the
Model
attribute and setting the collection name withcoll_name
: -
Connect to the database in one of two ways:
a. Establish a global connection:
.await; global_connect
b. Or connect locally:
.await; connect
For the global connection, Spark retains it throughout the program, accessible via:
Spark::get_db();
Usage
Instantiate the model:
let mut user = new_model;
Update attributes:
user.name = "Hossein".to_string;
user.age = 22;
Save to the database:
user.save.await.unwrap;
Find a model:
let mut user = new_model;
let sample = doc! ;
user.find_one.await.unwrap.unwrap;
println!;
Update and save:
let mut user = new_model;
user.name = "Hossein".to_string;
user.email = "spark_orm_test".to_string;
user.save.await;
user.name = "Nothing".to_string;
user.update.await;
Delete a record:
let mut user = new_model;
user.delete.await;
Attributes
Define index or unique attributes for struct fields:
These indexes are registered during the first initiation of Product.