1
1
# CRUD
2
2
3
- To perform database operations, one of the four crud macros is invoked.
3
+ To perform database operations, one of the four CRUD macros is invoked.
4
4
5
5
They all take an executor as their first argument (i.e. ` &Database ` or ` &mut Transaction ` )
6
6
and the model whose table to interact with as its second argument.
@@ -173,7 +173,7 @@ let posts: Vec<(String, UserWithoutPassword)> =
173
173
174
174
## Insert
175
175
176
- In order to create new rows in the database the insert! macro is used:
176
+ In order to create new rows in the database, the ` insert! ` macro is used:
177
177
178
178
``` rust
179
179
#[derive(Patch )]
@@ -269,7 +269,7 @@ pub async fn show_various_returns(db: &Database, user: &NewUser) -> Result<(), E
269
269
270
270
## Update
271
271
272
- In order to models' fields the ` update! ` macro is used:
272
+ In order to change models' fields the ` update! ` macro is used:
273
273
274
274
``` rust
275
275
pub async fn set_good_password (db : & Database ) -> Result <(), rorm :: Error > {
@@ -283,15 +283,15 @@ pub async fn set_good_password(db: &Database) -> Result<(), rorm::Error> {
283
283
284
284
### Dynamic mode and ` set_if `
285
285
286
- Before executing the query ` set ` has to be called at least once
287
- to set a value to set for a column (The first call changes the builders type).
286
+ Before executing the query, ` set ` has to be called at least once
287
+ to set a value for a column (the first call changes the builder's type).
288
288
Otherwise the query wouldn't do anything.
289
289
290
290
This can be limiting when your calls are made conditionally.
291
291
292
292
To support this, the builder can be put into a "dynamic" mode by calling ` begin_dyn_set ` .
293
293
Then calls to ` set ` won't change the type.
294
- When you're done use ` finish_dyn_set ` to go back to "normal" mode.
294
+ When you're done, use ` finish_dyn_set ` to go back to "normal" mode.
295
295
It will check the number of "sets" and return ` Result ` which is ` Ok ` for at least one and an ` Err ` for zero.
296
296
Both variants contain the builder in "normal" mode to continue.
297
297
@@ -382,10 +382,11 @@ To delete a single row, use the `single` method and pass it the model to delete.
382
382
` bulk ` is used like ` single ` but takes an iterator of instances and deletes all at once.
383
383
384
384
### ` .condition(...) `
385
- When you need more complex deleting logic than just concrete instance, you can use the ` conditon ` method.
385
+ When you need more complex deleting logic than just some concrete instances,
386
+ you can use the ` conditon ` method.
386
387
Any row which matches the provided condition will be deleted.
387
388
388
389
See [ query] ( crud.md#add-conditions ) for how conditions look.
389
390
390
391
### ` all() `
391
- For the case where you'd want to whip the whole table, you can use the ` all ` method
392
+ For the case where you'd want to wipe the whole table, you can use the ` all ` method.
0 commit comments