Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Oct 1, 2021
1 parent 0c05b4c commit 656e503
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions src/entity/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ pub trait FromQueryResult: Sized {
/// # .append_query_results(vec![vec![
/// # maplit::btreemap! {
/// # "name" => Into::<Value>::into("Chocolate Forest"),
/// # "num_of_cakes" => Into::<Value>::into(1),
/// # },
/// # maplit::btreemap! {
/// # "name" => Into::<Value>::into("New York Cheese"),
/// # "num_of_cakes" => Into::<Value>::into(1),
/// # "num_of_cakes" => Into::<Value>::into(2),
/// # },
/// # ]])
/// # .into_connection();
Expand All @@ -65,7 +61,7 @@ pub trait FromQueryResult: Sized {
/// #
/// let res: Vec<SelectResult> = SelectResult::find_by_statement(Statement::from_sql_and_values(
/// DbBackend::Postgres,
/// r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#,
/// r#"SELECT "name", COUNT(*) AS "num_of_cakes" FROM "cake" GROUP BY("name")"#,
/// vec![],
/// ))
/// .all(&db)
Expand All @@ -76,26 +72,21 @@ pub trait FromQueryResult: Sized {
/// vec![
/// SelectResult {
/// name: "Chocolate Forest".to_owned(),
/// num_of_cakes: 1,
/// },
/// SelectResult {
/// name: "New York Cheese".to_owned(),
/// num_of_cakes: 1,
/// num_of_cakes: 2,
/// },
/// ]
/// );
/// #
/// # Ok(())
/// # });
///
/// assert_eq!(
/// db.into_transaction_log(),
/// vec![Transaction::from_sql_and_values(
/// DbBackend::Postgres,
/// r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#,
/// vec![]
/// ),]
/// );
/// # assert_eq!(
/// # db.into_transaction_log(),
/// # vec![Transaction::from_sql_and_values(
/// # DbBackend::Postgres,
/// # r#"SELECT "name", COUNT(*) AS "num_of_cakes" FROM "cake" GROUP BY("name")"#,
/// # vec![]
/// # ),]
/// # );
/// ```
fn find_by_statement(stmt: Statement) -> SelectorRaw<SelectModel<Self>> {
SelectorRaw::<SelectModel<Self>>::from_statement(stmt)
Expand Down

0 comments on commit 656e503

Please sign in to comment.