Edit docs

This commit is contained in:
Chris Tsang 2021-11-14 16:58:52 +08:00
parent 2413c9e0f2
commit 5f2fa55253
10 changed files with 14 additions and 16 deletions

View File

@ -4,7 +4,7 @@ use crate::{
use futures::Stream; use futures::Stream;
use std::{future::Future, pin::Pin}; use std::{future::Future, pin::Pin};
/// Creates constraints for any structure that wants to create a database connection /// Creates constraints for any structure that can create a database connection
/// and execute SQL statements /// and execute SQL statements
#[async_trait::async_trait] #[async_trait::async_trait]
pub trait ConnectionTrait<'a>: Sync { pub trait ConnectionTrait<'a>: Sync {

View File

@ -23,7 +23,7 @@ pub struct MockDatabaseConnection {
mocker: Mutex<Box<dyn MockDatabaseTrait>>, mocker: Mutex<Box<dyn MockDatabaseTrait>>,
} }
/// A set of constraints for any type wanting to perform operations on the [MockDatabase] /// A Trait for any type wanting to perform operations on the [MockDatabase]
pub trait MockDatabaseTrait: Send + Debug { pub trait MockDatabaseTrait: Send + Debug {
/// Execute a statement in the [MockDatabase] /// Execute a statement in the [MockDatabase]
fn execute(&mut self, counter: usize, stmt: Statement) -> Result<ExecResult, DbErr>; fn execute(&mut self, counter: usize, stmt: Statement) -> Result<ExecResult, DbErr>;

View File

@ -76,12 +76,12 @@ where
ActiveValue::unchanged(value) ActiveValue::unchanged(value)
} }
/// Enforces a set of constraints on any type performing an Create, Update or Delete operation. /// A Trait for ActiveModel to perform Create, Update or Delete operation.
/// The type must also implement the [EntityTrait]. /// The type must also implement the [EntityTrait].
/// See module level docs [crate::entity] for a full example /// See module level docs [crate::entity] for a full example
#[async_trait] #[async_trait]
pub trait ActiveModelTrait: Clone + Debug { pub trait ActiveModelTrait: Clone + Debug {
/// Enforce the type to the constraints of the [EntityTrait] /// The Entity this ActiveModel belongs to
type Entity: EntityTrait; type Entity: EntityTrait;
/// Get a mutable [ActiveValue] from an ActiveModel /// Get a mutable [ActiveValue] from an ActiveModel
@ -208,9 +208,7 @@ pub trait ActiveModelTrait: Clone + Debug {
} }
} }
/// Enforce a set of constraints to a override the ActiveModel behavior /// A Trait for overriding the ActiveModel behavior
/// Behaviors for users to override.
/// The type must also implement the [ActiveModelTrait]
/// ///
/// ### Example /// ### Example
/// ```ignore /// ```ignore
@ -265,7 +263,7 @@ pub trait ActiveModelBehavior: ActiveModelTrait {
} }
} }
/// Enforce constraints for conversion to an ActiveModel /// A Trait for any type that can be converted into an ActiveModel
pub trait IntoActiveModel<A> pub trait IntoActiveModel<A>
where where
A: ActiveModelTrait, A: ActiveModelTrait,

View File

@ -13,7 +13,7 @@ pub trait IdenStatic: Iden + Copy + Debug + 'static {
fn as_str(&self) -> &str; fn as_str(&self) -> &str;
} }
/// Enforces the naming of an entity to a set of constraints /// A Trait for mapping an Entity to a database table
pub trait EntityName: IdenStatic + Default { pub trait EntityName: IdenStatic + Default {
/// Method to get the name for the schema, defaults to [Option::None] if not set /// Method to get the name for the schema, defaults to [Option::None] if not set
fn schema_name(&self) -> Option<&str> { fn schema_name(&self) -> Option<&str> {

View File

@ -6,7 +6,7 @@ use sea_query::{Alias, IntoIden, JoinType, SeaRc};
/// Same as [RelationDef] /// Same as [RelationDef]
pub type LinkDef = RelationDef; pub type LinkDef = RelationDef;
/// A set of constraints for links between Entities /// A Trait for links between Entities
pub trait Linked { pub trait Linked {
#[allow(missing_docs)] #[allow(missing_docs)]
type FromEntity: EntityTrait; type FromEntity: EntityTrait;

View File

@ -5,7 +5,7 @@ use crate::{
pub use sea_query::Value; pub use sea_query::Value;
use std::fmt::Debug; use std::fmt::Debug;
/// A set of constraints for a Model /// A Trait for a Model
pub trait ModelTrait: Clone + Send + Debug { pub trait ModelTrait: Clone + Send + Debug {
#[allow(missing_docs)] #[allow(missing_docs)]
type Entity: EntityTrait; type Entity: EntityTrait;
@ -35,7 +35,7 @@ pub trait ModelTrait: Clone + Send + Debug {
} }
} }
/// A set of constraints for implementing a [QueryResult] /// A Trait for implementing a [QueryResult]
pub trait FromQueryResult: Sized { pub trait FromQueryResult: Sized {
/// Instantiate a Model from a [QueryResult] /// Instantiate a Model from a [QueryResult]
fn from_query_result(res: &QueryResult, pre: &str) -> Result<Self, DbErr>; fn from_query_result(res: &QueryResult, pre: &str) -> Result<Self, DbErr>;

View File

@ -4,7 +4,7 @@ use sea_query::{FromValueTuple, IntoValueTuple};
use std::fmt::Debug; use std::fmt::Debug;
//LINT: composite primary key cannot auto increment //LINT: composite primary key cannot auto increment
/// A set of constraints to be used to define a Primary Key. /// A Trait for to be used to define a Primary Key.
/// ///
/// A primary key can be derived manually /// A primary key can be derived manually
/// ///

View File

@ -159,7 +159,7 @@ where
} }
#[async_trait::async_trait] #[async_trait::async_trait]
/// Used to enforce constraints on any type that wants to paginate results /// A Trait for any type that can paginate results
pub trait PaginatorTrait<'db, C> pub trait PaginatorTrait<'db, C>
where where
C: ConnectionTrait<'db>, C: ConnectionTrait<'db>,

View File

@ -31,7 +31,7 @@ where
selector: S, selector: S,
} }
/// Used to enforce constraints on any type that wants to perform SELECT queries /// A Trait for any type that can perform SELECT queries
pub trait SelectorTrait { pub trait SelectorTrait {
#[allow(missing_docs)] #[allow(missing_docs)]
type Item: Sized; type Item: Sized;

View File

@ -1,7 +1,7 @@
use crate::{DbBackend, Statement}; use crate::{DbBackend, Statement};
use sea_query::QueryStatementBuilder; use sea_query::QueryStatementBuilder;
/// Enforces a set of constraints to any type performing queries on a Model or ActiveModel /// A Trait for any type performing queries on a Model or ActiveModel
pub trait QueryTrait { pub trait QueryTrait {
/// Constrain the QueryStatement to [QueryStatementBuilder] trait /// Constrain the QueryStatement to [QueryStatementBuilder] trait
type QueryStatement: QueryStatementBuilder; type QueryStatement: QueryStatementBuilder;