Rename load_sql to read_sql
This commit is contained in:
parent
b07c64fec0
commit
21b3411c28
1 changed files with 4 additions and 3 deletions
|
@ -61,8 +61,8 @@ fn establish_connection() -> Result<PgConnection, CacheError> {
|
||||||
Ok(PgConnection::establish(&database_url)?)
|
Ok(PgConnection::establish(&database_url)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load data from the cache, and return a vector of Cache.
|
/// Read data from the cache, and return a vector of Cache.
|
||||||
fn load_sql() -> Result<Vec<Cache>, CacheError> {
|
fn read_sql() -> Result<Vec<Cache>, CacheError> {
|
||||||
let connection = &mut establish_connection()?;
|
let connection = &mut establish_connection()?;
|
||||||
let results = cache.filter(name.eq("Debian")).load::<Cache>(connection)?;
|
let results = cache.filter(name.eq("Debian")).load::<Cache>(connection)?;
|
||||||
|
|
||||||
|
@ -88,7 +88,8 @@ fn insert_sql(conn: &mut PgConnection, new_name: &str, new_domain: &str, new_ip:
|
||||||
/// SQL cache function to be called by `get_data` (read) and `api_client` (write).
|
/// SQL cache function to be called by `get_data` (read) and `api_client` (write).
|
||||||
pub fn sql_cache() {
|
pub fn sql_cache() {
|
||||||
let connection = &mut establish_connection().unwrap();
|
let connection = &mut establish_connection().unwrap();
|
||||||
let data = match load_sql() {
|
|
||||||
|
let data = match read_sql() {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Unable to load data: {err}");
|
eprintln!("Unable to load data: {err}");
|
||||||
|
|
Loading…
Reference in a new issue