Skip to main content

Query

Trait Query 

Source
pub trait Query {
    type Model;

    const TABLE_NAME: &'static str;
    const PRIMARY_KEY: &'static str = "id";

    // Required method
    fn process_row(row: &Row<'_>) -> Self::Model;

    // Provided methods
    fn query(
        conn: &Connection,
        query: &str,
        params: impl Params,
    ) -> Vec<Self::Model> { ... }
    fn get(
        conn: &Connection,
        query: &str,
        params: impl Params,
    ) -> Result<Self::Model> { ... }
    fn get_by_id<'a, T>(conn: &Connection, id: &'a T) -> Option<Self::Model>
       where T: Clone + 'a,
             Value: From<T> { ... }
    fn query_by_ids<'a, I: ?Sized, T>(
        conn: &Connection,
        ids: &'a I,
    ) -> Vec<Self::Model>
       where &'a I: IntoIterator<Item = &'a T>,
             T: Clone + 'a,
             Value: From<T> { ... }
    fn delete_by_ids<'a, I: ?Sized, T>(
        conn: &Connection,
        ids: &'a I,
    ) -> Vec<Self::Model>
       where &'a I: IntoIterator<Item = &'a T>,
             T: Clone + 'a,
             Value: From<T> { ... }
    fn table_name() -> &'static str { ... }
    fn all(conn: &Connection) -> Vec<Self::Model> { ... }
    fn all_with_limit(conn: &Connection, limit: usize) -> Vec<Self::Model> { ... }
}

Required Associated Constants§

Source

const TABLE_NAME: &'static str

Provided Associated Constants§

Source

const PRIMARY_KEY: &'static str = "id"

Required Associated Types§

Required Methods§

Source

fn process_row(row: &Row<'_>) -> Self::Model

Provided Methods§

Source

fn query( conn: &Connection, query: &str, params: impl Params, ) -> Vec<Self::Model>

Source

fn get( conn: &Connection, query: &str, params: impl Params, ) -> Result<Self::Model>

Source

fn get_by_id<'a, T>(conn: &Connection, id: &'a T) -> Option<Self::Model>
where T: Clone + 'a, Value: From<T>,

Source

fn query_by_ids<'a, I: ?Sized, T>( conn: &Connection, ids: &'a I, ) -> Vec<Self::Model>
where &'a I: IntoIterator<Item = &'a T>, T: Clone + 'a, Value: From<T>,

Source

fn delete_by_ids<'a, I: ?Sized, T>( conn: &Connection, ids: &'a I, ) -> Vec<Self::Model>
where &'a I: IntoIterator<Item = &'a T>, T: Clone + 'a, Value: From<T>,

Source

fn table_name() -> &'static str

Source

fn all(conn: &Connection) -> Vec<Self::Model>

Source

fn all_with_limit(conn: &Connection, limit: usize) -> Vec<Self::Model>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Query for Accession

Source§

const TABLE_NAME: &'static str = "accessions"

Source§

type Model = Accession

Source§

impl Query for AccessionEdge

Source§

const TABLE_NAME: &'static str = "accession_edges"

Source§

type Model = AccessionEdge

Source§

impl Query for AccessionPath

Source§

const TABLE_NAME: &'static str = "accession_paths"

Source§

type Model = AccessionPath

Source§

impl Query for Annotation

Source§

const TABLE_NAME: &'static str = "annotations"

Source§

type Model = Annotation

Source§

impl Query for AnnotationFile

Source§

const TABLE_NAME: &'static str = "annotation_files"

Source§

type Model = AnnotationFile

Source§

impl Query for AnnotationGroup

Source§

const PRIMARY_KEY: &'static str = "name"

Source§

const TABLE_NAME: &'static str = "annotation_groups"

Source§

type Model = AnnotationGroup

Source§

impl Query for BlockGroup

Source§

const TABLE_NAME: &'static str = "block_groups"

Source§

type Model = BlockGroup

Source§

impl Query for BlockGroupEdge

Source§

const TABLE_NAME: &'static str = "block_group_edges"

Source§

type Model = BlockGroupEdge

Source§

impl Query for Collection

Source§

const PRIMARY_KEY: &'static str = "name"

Source§

const TABLE_NAME: &'static str = "collections"

Source§

type Model = Collection

Source§

impl Query for Edge

Source§

const TABLE_NAME: &'static str = "edges"

Source§

type Model = Edge

Source§

impl Query for GenDatabase

Source§

const PRIMARY_KEY: &'static str = "db_uuid"

Source§

const TABLE_NAME: &'static str = "gen_databases"

Source§

type Model = GenDatabase

Source§

impl Query for Metadata

Source§

const TABLE_NAME: &'static str = "gen_metadata"

Source§

type Model = Metadata

Source§

impl Query for Node

Source§

const TABLE_NAME: &'static str = "nodes"

Source§

type Model = Node

Source§

impl Query for Branch

Source§

const TABLE_NAME: &'static str = "branches"

Source§

type Model = Branch

Source§

impl Query for Defaults

Source§

const TABLE_NAME: &'static str = "defaults"

Source§

type Model = Defaults

Source§

impl Query for FileAddition

Source§

const TABLE_NAME: &'static str = "file_additions"

Source§

type Model = FileAddition

Source§

impl Query for Operation

Source§

const PRIMARY_KEY: &'static str = "hash"

Source§

const TABLE_NAME: &'static str = "operations"

Source§

type Model = Operation

Source§

impl Query for OperationSummary

Source§

const TABLE_NAME: &'static str = "operation_summaries"

Source§

type Model = OperationSummary

Source§

impl Query for Remote

Source§

const TABLE_NAME: &'static str = "remotes"

Source§

type Model = Remote

Source§

impl Query for Path

Source§

const TABLE_NAME: &'static str = "paths"

Source§

type Model = Path

Source§

impl Query for PathEdge

Source§

const TABLE_NAME: &'static str = "path_edges"

Source§

type Model = PathEdge

Source§

impl Query for Sample

Source§

const PRIMARY_KEY: &'static str = "name"

Source§

const TABLE_NAME: &'static str = "samples"

Source§

type Model = Sample

Source§

impl Query for Sequence

Source§

const PRIMARY_KEY: &'static str = "hash"

Source§

const TABLE_NAME: &'static str = "sequences"

Source§

type Model = Sequence