Inline the Insertable trait into root, document it

I don't want to expose the `persistable` namespace, as I might change it
in the future. `Insertable` is the only thing in there that matters.
This commit is contained in:
Sean Griffin 2015-11-29 08:38:00 -07:00
parent a28ca14c7d
commit be4f4880b0
4 changed files with 10 additions and 2 deletions

View File

@ -252,7 +252,7 @@ you can go about getting the data structures set up.
[table]: http://sgrif.github.io/yaqb/yaqb/macro.table!.html [table]: http://sgrif.github.io/yaqb/yaqb/macro.table!.html
[queriable]: http://sgrif.github.io/yaqb/yaqb/query_source/trait.Queriable.html [queriable]: http://sgrif.github.io/yaqb/yaqb/query_source/trait.Queriable.html
[insertable]: http://sgrif.github.io/yaqb/yaqb/persistable/trait.Insertable.html [insertable]: http://sgrif.github.io/yaqb/yaqb/trait.Insertable.html
[insert]: http://sgrif.github.io/yaqb/yaqb/struct.Connection.html#method.insert [insert]: http://sgrif.github.io/yaqb/yaqb/struct.Connection.html#method.insert
[insert_returning_count]: http://sgrif.github.io/yaqb/yaqb/struct.Connection.html#method.insert_returning_count [insert_returning_count]: http://sgrif.github.io/yaqb/yaqb/struct.Connection.html#method.insert_returning_count
[execute_returning_count]: http://sgrif.github.io/yaqb/yaqb/struct.Connection.html#method.execute_returning_count [execute_returning_count]: http://sgrif.github.io/yaqb/yaqb/struct.Connection.html#method.execute_returning_count

View File

@ -1,5 +1,6 @@
#![deny(warnings)] #![deny(warnings)]
pub mod expression; pub mod expression;
#[doc(hidden)]
pub mod persistable; pub mod persistable;
pub mod types; pub mod types;
@ -59,4 +60,6 @@ pub use expression::{Expression, SelectableExpression, BoxableExpression};
pub use expression::expression_methods::*; pub use expression::expression_methods::*;
pub use query_dsl::*; pub use query_dsl::*;
pub use query_source::{QuerySource, Queriable, Table, Column, JoinTo}; pub use query_source::{QuerySource, Queriable, Table, Column, JoinTo};
#[doc(inline)]
pub use persistable::Insertable;
pub use result::{QueryResult, TransactionError, TransactionResult, ConnectionError, ConnectionResult}; pub use result::{QueryResult, TransactionError, TransactionResult, ConnectionError, ConnectionResult};

View File

@ -5,6 +5,11 @@ use query_builder::{QueryBuilder, BuildQueryResult};
use query_source::{Table, Column}; use query_source::{Table, Column};
use types::NativeSqlType; use types::NativeSqlType;
/// Represents that a structure can be used to to insert a new row into the database.
/// Implementations can be automatically generated by
/// [`#[insertable_into]`](https://github.com/sgrif/yaqb/tree/master/yaqb_codegen#insertable_intotable_name).
/// This is automatically implemented for `&[T]`, `Vec<T>` and `&Vec<T>` for inserting more than
/// one record.
pub trait Insertable<T: Table> { pub trait Insertable<T: Table> {
type Columns: InsertableColumns<T>; type Columns: InsertableColumns<T>;
type Values: Expression<SqlType=<Self::Columns as InsertableColumns<T>>::SqlType>; type Values: Expression<SqlType=<Self::Columns as InsertableColumns<T>>::SqlType>;

View File

@ -109,7 +109,7 @@ This will persist the model to the database and update it with any fields the
database returns. database returns.
[queriable]: http://sgrif.github.io/yaqb/yaqb/query_source/trait.Queriable.html [queriable]: http://sgrif.github.io/yaqb/yaqb/query_source/trait.Queriable.html
[insertable]: http://sgrif.github.io/yaqb/yaqb/persistable/trait.Insertable.html [insertable]: http://sgrif.github.io/yaqb/yaqb/trait.Insertable.html
[as_changeset]: http://sgrif.github.io/yaqb/yaqb/query_builder/update_statement/changeset/trait.AsChangeset.html [as_changeset]: http://sgrif.github.io/yaqb/yaqb/query_builder/update_statement/changeset/trait.AsChangeset.html
Field annotations Field annotations