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

Augment DB-related examples #955

Closed
nahuakang opened this issue Apr 22, 2022 · 6 comments
Closed

Augment DB-related examples #955

nahuakang opened this issue Apr 22, 2022 · 6 comments

Comments

@nahuakang
Copy link
Contributor

Feature Request

Thanks for creating axum :) I'm new and have not read all the examples/discussions so this request might have been discussed before already. I feel like raising this topic since it'd benefit me personally.

Motivation

As a beginner in using Rust & axum to write APIs, I'd appreciate slightly more detailed examples (e.g. sqlx-postgres and tokio-postgres) that contain serializing/deserializing data and write/read from DB. This aspect for actix-web has been covered quite well on the internet. Maybe it's a better experience for a new Rustacean to land on axum and just get those examples readily provided instead of searching for an equivalent blog/sample on another framework and migrate the code into axum?

Proposal

Expand the examples sqlx-postgres and tokio-postgres to include some dummy models to serialize/deserialize as well as for read/write from DB.

Alternatives

Insert some blog posts from axum users who write about how to interact with DB. I could not find any satisfactory examples myself.

@davidpdrsn
Copy link
Member

Do you mean like deserializing data from POST requests? That is covered in other examples and on docs.rs. You probably want Json.

The examples intentionally only cover how to integrate things with axum. For examples on how to actually use tokio-postgres and sqlx you should look at their examples. That is why the examples don't contain any migrations, because its not really relevant for integration with axum.

For more extensive examples I recommend looking at ECOSYSTEM.md. There a few demo apps. Probably this one being the easiest to get into.

@nahuakang
Copy link
Contributor Author

@davidpdrsn Thanks for the links. The last link you provided is one that I was looking for. Your explanation makes sense me. One final comment before closing the issue: perhaps the demos could be linked somewhere in the doc on Github for reference?

@davidpdrsn
Copy link
Member

perhaps the demos could be linked somewhere in the doc on Github for reference?

What doc do you mean?

@nahuakang
Copy link
Contributor Author

Bad wording. Perhaps the main README or inside the README of the examples directory?

@davidpdrsn
Copy link
Member

Yeah sure. Do you wanna make a PR for that?

@davidpdrsn
Copy link
Member

Fixed in #956

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

No branches or pull requests

2 participants