// Get a list of records from the database
Get a list of records from the database
Get a list of records from the database
pub fn list_records(a_date: i64, b_date: i64, search: String, description: bool, title: bool, 
    config: &models::Config) -> rusqlite::Result<Vec<models::AnnotationRecord>> {
    // Create a connection and get all the database entries
    let mut sole = false;
    let records: Vec<models::AnnotationRecord>;
    let conn =  rusqlite::Connection::open(&config.database.file.as_path()).unwrap();
    if a_date > 0 && b_date > 0 {
        let query = assemble_query(&config.database.interval_annotation, 
            description, title, sole, config);
        let mut stmt = conn.prepare(&query)?;
        let rows = stmt.query([a_date, b_date])?;
        records = get_records(rows, search);
    } else if a_date > 0 {
        let query = assemble_query(&config.database.after_annotation, 
            description, title, sole, config);
        let mut stmt = conn.prepare(&query)?;
        let rows = stmt.query([a_date])?;
        records = get_records(rows, search);
    } else if b_date > 0 {
        let query = assemble_query(&config.database.before_annotation, 
            description, title, sole, config);
        let mut stmt = conn.prepare(&query)?;
        let rows = stmt.query([b_date])?;
        records = get_records(rows, search);
    } else {
        sole = true;
        let query = assemble_query(&config.database.all_annotation, 
            description, title, sole, config);
        let mut stmt = conn.prepare(&query)?;
        let rows = stmt.query([])?;
        records = get_records(rows, search);
    }
    Ok(records)
}
pub fn list_records ( a_date : i64 , b_date : i64 , search : String , description : bool , title : bool , config : & models :: Config ) -> rusqlite :: Result < Vec < models :: AnnotationRecord > > { // Create a connection and get all the database entries let mut sole = false ; let records : Vec < models :: AnnotationRecord > ; let conn = rusqlite :: Connection :: open ( & config . database . file . as_path ( ) ) . unwrap ( ) ; if a_date > 0 && b_date > 0 { let query = assemble_query ( & config . database . interval_annotation , description , title , sole , config ) ; let mut stmt = conn . prepare ( & query ) ? ; let rows = stmt . query ( [ a_date , b_date ] ) ? ; records = get_records ( rows , search ) ; } else if a_date > 0 { let query = assemble_query ( & config . database . after_annotation , description , title , sole , config ) ; let mut stmt = conn . prepare ( & query ) ? ; let rows = stmt . query ( [ a_date ] ) ? ; records = get_records ( rows , search ) ; } else if b_date > 0 { let query = assemble_query ( & config . database . before_annotation , description , title , sole , config ) ; let mut stmt = conn . prepare ( & query ) ? ; let rows = stmt . query ( [ b_date ] ) ? ; records = get_records ( rows , search ) ; } else { sole = true ; let query = assemble_query ( & config . database . all_annotation , description , title , sole , config ) ; let mut stmt = conn . prepare ( & query ) ? ; let rows = stmt . query ( [ ] ) ? ; records = get_records ( rows , search ) ; } Ok ( records ) }
Get a list of records from the database
Get a list of records from the database
a_date
i64
b_date
i64
search
String
description
bool
title
bool
config
&models::Config