Expand description
§IC-NoSQL: A flexible NoSQL database library for Internet Computer canisters
This library provides a comprehensive NoSQL database solution built on top of IC’s stable memory structures, with support for multiple models, secondary indexes, flexible memory management, and type-safe operations.
§Features
- Multiple Model Support: Register and manage different data models in a single canister
- Secondary Indexes: Optional secondary indexes for efficient querying
- Memory Management: Automatic memory allocation with conflict prevention
- Type Safety: Compile-time type checking for all database operations
- Pagination: Built-in pagination support for large result sets
- Macros: Easy model definition with the
define_model!
macro
§Quick Start
use ic_nosql::{DatabaseManager, CandidType, Deserialize, Serialize};
// Define a model
#[derive(Debug, Clone, CandidType, Deserialize, Serialize)]
pub struct User {
pub id: String,
pub username: String,
pub email: String,
}
// Initialize database manager
let db_manager = DatabaseManager::new();
// Register the model
db_manager.register_model("users", None, None).unwrap();
// Use the database
let user = User {
id: "1".to_string(),
username: "alice".to_string(),
email: "alice@example.com".to_string()
};
db_manager.insert("users", "1", &user).unwrap();
let retrieved_user = db_manager.get::<User>("users", "1").unwrap();
Re-exports§
pub use database::Database;
pub use database::DatabaseManager;
pub use memory::MemoryManager;
pub use traits::Model;
pub use traits::Query;
pub use traits::Repository;
Modules§
- database
- Database module providing core database functionality
- macros
- Macros module providing helper macros for model definition
- memory
- Memory management module for database operations
- traits
- Traits module providing database abstractions
- utils
- Utilities module providing helper functions
Macros§
- define_
model - Macro to easily define a model that implements all necessary traits
Structs§
Traits§
- Candid
Type - Deserialize
- A data structure that can be deserialized from any data format supported by Serde.
- Serialize
- A data structure that can be serialized into any data format supported by Serde.
- Storable
- A trait with convenience methods for storing an element into a stable structure.