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

Update main README to have more consistent style #3704

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![](https://diesel.rs/assets/images/diesel_logo_stacked_black.png)](https://diesel.rs)
[![diesel logo](https://diesel.rs/assets/images/diesel_logo_stacked_black.png)](https://diesel.rs)

# A safe, extensible ORM and Query Builder for Rust

A safe, extensible ORM and Query Builder for Rust
==========================================================
[![Build Status](https://github.com/diesel-rs/diesel/workflows/CI%20Tests/badge.svg)](https://github.com/diesel-rs/diesel/actions?query=workflow%3A%22CI+Tests%22+branch%3Amaster)
[![Gitter](https://badges.gitter.im/diesel-rs/diesel.svg)](https://gitter.im/diesel-rs/diesel?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crates.io](https://img.shields.io/crates/v/diesel.svg)](https://crates.io/crates/diesel)
Expand All @@ -21,6 +21,7 @@ Supported databases:
3. [SQLite](https://docs.diesel.rs/master/diesel/sqlite/index.html)

You can configure the database backend in `Cargo.toml`:

```toml
[dependencies]
diesel = { version = "<version>", features = ["<postgres|mysql|sqlite>"] }
Expand All @@ -33,19 +34,19 @@ Find our extensive Getting Started tutorial at
Guides on more specific features are coming soon.

## Getting help

If you run into problems, Diesel has a very active Gitter room.
You can come ask for help at
[gitter.im/diesel-rs/diesel](https://gitter.im/diesel-rs/diesel).
For help with longer questions and discussion about the future of Diesel,
open a discussion on [GitHub Discussions](https://github.com/diesel-rs/diesel/discussions).

## Usage
## Usage

### Simple queries
### Simple queries

Simple queries are a complete breeze. Loading all users from a database:


```rust
users::table.load(&mut connection)
```
Expand Down Expand Up @@ -86,6 +87,7 @@ let downloads = version_downloads
```

Executed SQL:

```sql
SELECT version_downloads.*
WHERE date > (NOW() - '90 days')
Expand Down Expand Up @@ -172,7 +174,6 @@ INSERT INTO users (name, hair_color) VALUES

If you need data from the rows you inserted, just change `execute` to `get_result` or `get_results`. Diesel will take care of the rest.


```rust
let new_users = vec![
NewUser { name: "Sean", hair_color: Some("Black") },
Expand All @@ -194,6 +195,7 @@ INSERT INTO users (name, hair_color) VALUES
```

### Updating data

Diesel's codegen can generate several ways to update a row, letting you encapsulate your logic in the way that makes sense for your app.

Modifying a struct:
Expand All @@ -219,7 +221,7 @@ update(Settings::belonging_to(current_user))
.execute(&mut connection)
```

### Raw SQL
### Raw SQL

There will always be certain queries that are just easier to write as raw SQL, or can't be expressed with the query builder. Even in these cases, Diesel provides an easy to use API for writing raw SQL.

Expand All @@ -242,7 +244,6 @@ sql_query(include_str!("complex_users_by_organization.sql"))
.load::<User>(&mut conn)?;
```


## Code of conduct

Anyone who interacts with Diesel in any space, including but not limited to
Expand All @@ -258,6 +259,7 @@ Licensed under either of these:
https://opensource.org/licenses/MIT)

### Contributing

Before contributing, please read the [contributors guide](https://github.com/diesel-rs/diesel/blob/master/CONTRIBUTING.md)
for useful information about setting up Diesel locally, coding style and common abbreviations.

Expand Down
Loading