Skip to content
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

Refactor: Moving client code to lib.rs #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

aryansri-19
Copy link

No description provided.

Copy link
Member

@GetPsyched GetPsyched left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, you moved the code to db/mod.rs instead of lib.rs.

Also, these won't be independent functions but methods on the Task struct itself.

So, this would look something like:

impl Task {
    pub fn create(...) -> Self {}
    pub fn update(&mut self, ...) {}
}

@aryansri-19
Copy link
Author

Uh, you moved the code to db/mod.rs instead of lib.rs.

Also, these won't be independent functions but methods on the Task struct itself.

So, this would look something like:

impl Task {
    pub fn create(...) -> Self {}
    pub fn update(&mut self, ...) {}
}

But if they are functions on the database, then shouldn't they be in db module?

@GetPsyched
Copy link
Member

I guess you could do it that way too. I prefer putting it in Task because if that way all of the Task related code is in one place; the benefit of this would be clearer once we have more structs

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/db/mod.rs Outdated
Comment on lines 10 to 11
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've initialised a configuration module.

Suggested change
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let database_url = get_configuration().connection_string();

And cleanup the remaining code (like removing dotenv from cargo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants