Skip to content

Commit

Permalink
refactor: re-export native_model, closes #301
Browse files Browse the repository at this point in the history
  • Loading branch information
imbolc authored and vincent-herlemont committed Jan 5, 2025
1 parent ecc25ff commit 2dee0af
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 47 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ Add this to your `Cargo.toml`:
```toml
[dependencies]
native_db = "0.8.1"
native_model = "0.4.20"
```

NOTE: `native_db` requires `native_model` to work.

# Status

Active development. The API is not stable yet and may change in the future.
Expand All @@ -59,7 +56,7 @@ If you want to propose your project or company that uses Native DB, please open
```rust
use serde::{Deserialize, Serialize};
use native_db::*;
use native_model::{native_model, Model};
use native_db::native_model::{native_model, Model};
use once_cell::sync::Lazy;

#[derive(Serialize, Deserialize, PartialEq, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/db_type/key/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Key {
/// ## Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Key {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone, Hash)]
Expand Down Expand Up @@ -124,7 +124,7 @@ impl Key {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down
36 changes: 26 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@
//!
//! ```rust
//! pub mod data {
//! use native_db::{native_db, ToKey};
//! use native_model::{native_model, Model};
//! use native_db::{
//! native_db,
//! native_model::{self, native_model, Model},
//! ToKey,
//! };
//! use serde::{Deserialize, Serialize};
//!
//! pub type Person = v1::Person;
Expand All @@ -111,8 +114,11 @@
//!
//! ```rust
//! # pub mod data {
//! # use native_db::{native_db, ToKey};
//! # use native_model::{native_model, Model};
//! # use native_db::{
//! # native_db,
//! # native_model::{self, native_model, Model},
//! # ToKey,
//! # };
//! # use serde::{Deserialize, Serialize};
//! #
//! # pub type Person = v1::Person;
Expand Down Expand Up @@ -156,8 +162,11 @@
//!
//! ```rust
//! # pub mod data {
//! # use native_db::{native_db, ToKey};
//! # use native_model::{native_model, Model};
//! # use native_db::{
//! # native_db,
//! # native_model::{self, native_model, Model},
//! # ToKey,
//! # };
//! # use serde::{Deserialize, Serialize};
//! #
//! # pub type Person = v1::Person;
Expand Down Expand Up @@ -213,8 +222,11 @@
//! ```rust
//! pub mod data {
//! // ... same imports
//! # use native_db::{native_db, ToKey};
//! # use native_model::{native_model, Model};
//! # use native_db::{
//! # native_db,
//! # native_model::{self, native_model, Model},
//! # ToKey,
//! # };
//! # use serde::{Deserialize, Serialize};
//!
//! // Update the type alias to the latest version
Expand Down Expand Up @@ -271,8 +283,11 @@
//! ```rust
//! # pub mod data {
//! # // ... same imports
//! # use native_db::{native_db, ToKey};
//! # use native_model::{native_model, Model};
//! # use native_db::{
//! # native_db,
//! # native_model::{self, native_model, Model},
//! # ToKey,
//! # };
//! # use serde::{Deserialize, Serialize};
//! #
//! # // Update the type alias to the latest version
Expand Down Expand Up @@ -374,6 +389,7 @@ pub use db_type::Key;
pub use db_type::ToInput;
/// Allow to use a type as a key in the database.
pub use db_type::ToKey;
pub use native_model;

// Export
pub use database::*;
Expand Down
19 changes: 11 additions & 8 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ use crate::{db_type::Result, table_definition::NativeModelOptions, ModelBuilder,
///
/// ```rust
/// # pub mod data {
/// # use native_db::{native_db, ToKey};
/// # use native_model::{native_model, Model};
/// # use native_db::{
/// # native_db,
/// # native_model::{self, native_model, Model},
/// # ToKey,
/// # };
/// # use serde::{Deserialize, Serialize};
/// #
/// # pub type Person = v1::Person;
Expand Down Expand Up @@ -107,7 +110,7 @@ impl Models {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand All @@ -131,7 +134,7 @@ impl Models {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -176,7 +179,7 @@ impl Models {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand All @@ -198,7 +201,7 @@ impl Models {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -237,7 +240,7 @@ impl Models {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -280,7 +283,7 @@ impl Models {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/query/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RGet<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -62,7 +62,7 @@ impl RGet<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/query/len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl RLen<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -54,7 +54,7 @@ impl RLen<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down
6 changes: 3 additions & 3 deletions src/transaction/query/scan/primary_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ where
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down Expand Up @@ -66,7 +66,7 @@ where
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down Expand Up @@ -109,7 +109,7 @@ where
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down
6 changes: 3 additions & 3 deletions src/transaction/query/scan/secondary_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down Expand Up @@ -98,7 +98,7 @@ where
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down Expand Up @@ -157,7 +157,7 @@ where
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
/// use itertools::Itertools;
///
Expand Down
12 changes: 6 additions & 6 deletions src/transaction/rw_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'db, 'txn> RwTransaction<'db> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<'db, 'txn> RwTransaction<'db> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -216,7 +216,7 @@ impl<'db, 'txn> RwTransaction<'db> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -266,7 +266,7 @@ impl<'db, 'txn> RwTransaction<'db> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -314,7 +314,7 @@ impl<'db, 'txn> RwTransaction<'db> {
///
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -402,7 +402,7 @@ impl<'db, 'txn> RwTransaction<'db> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/watch/query/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl WatchGet<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -58,7 +58,7 @@ impl WatchGet<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down
8 changes: 4 additions & 4 deletions src/watch/query/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl WatchScanPrimary<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -90,7 +90,7 @@ impl WatchScanPrimary<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -136,7 +136,7 @@ impl WatchScanSecondary<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -178,7 +178,7 @@ impl WatchScanSecondary<'_, '_> {
/// # Example
/// ```rust
/// use native_db::*;
/// use native_model::{native_model, Model};
/// use native_db::native_model::{native_model, Model};
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
Expand Down

0 comments on commit 2dee0af

Please sign in to comment.