-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: db.rs for inserting and querying profiles #4
base: master
Are you sure you want to change the base?
Conversation
@@ -1,2 +1,3 @@ | |||
/target | |||
/result | |||
.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every file needs to end with a line break.
.env | |
.env | |
select_all_users().await?; | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
} | |
} | |
|
||
#[tokio::main] | ||
async fn main() { | ||
if let Err(e) = db::run_db_operations().await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Abstract that out to a variable; conciseness is good but this harms readability.
use std::env; | ||
|
||
pub async fn insert_user(name: &str, age: i32) -> Result<(), Error> { | ||
dotenv().ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't explored this yet but there's probably a better place for this? I can't imagine doing this in every single function.
|
||
pub async fn insert_user(name: &str, age: i32) -> Result<(), Error> { | ||
dotenv().ok(); | ||
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too, probably should be attached to some global/pseudo-global context that is available readily.
i assumed the dummy table as: