pub mod models;
pub use models::*;
use lazy_static::lazy_static;
use crate::core::mongo;
use crate::core::error2::Error;
use crate::core::error2::Result;
lazy_static! {
pub static ref GPS_DB: &'static str = "gps_db";
pub static ref GPS_COL: &'static str = "t_user_gps";
}
pub async fn save_gps(
client: &mongo::MongoClient,
user_id: &str,
lat: &str,
lon: &str,
timestamp: i64,
) -> Result<String> {
let r = GpsRecord {
user_id: user_id.to_string(),
lat: lat.to_string(),
lon: lon.to_string(),
timestamp,
};
client
.insert_one(*GPS_DB, *GPS_COL, r)
.await
.map_err(Error::run_time)
}