You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-11Lines changed: 16 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ diesel::table! {
24
24
We run:
25
25
26
26
```sh
27
-
cargo dsync -i schema.rs -o models
27
+
dsync -i schema.rs -o models
28
28
```
29
29
30
30
Now we have everything we need!
@@ -45,9 +45,9 @@ async fn demo(db: Connection) {
45
45
}
46
46
```
47
47
48
-
For a complete example, see [`test/simple_table/schema.rs`](test/simple_table/schema.rs) which generates all the code in [`test/simple_schema/models`](test/simple_table/models).
48
+
For a complete example, see [`test/simple_table_sqlite/schema.rs`](test/simple_table_sqlite/schema.rs) which generates all the code in [`test/simple_schema_sqlite/models`](test/simple_table_sqlite/models).
49
49
50
-
## Usage
50
+
## Usage as a library
51
51
52
52
1. Add this crate:
53
53
@@ -67,7 +67,10 @@ For a complete example, see [`test/simple_table/schema.rs`](test/simple_table/sc
67
67
dsync::generate_files(
68
68
PathBuf::from_iter([dir, "src/schema.rs"]),
69
69
PathBuf::from_iter([dir, "src/models"]),
70
-
GenerationConfig { /* ... your generation options ... */ }
*`-o`: output argument: path to directory where generated code should be written
109
-
*`-c`: connection type (for example: `diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::pg::PgConnection>>`)
110
+
*`-i`: path to the diesel schema file
111
+
*`-o`: model output directory
112
+
*`-c`: connection type (for example: `diesel::sqlite::SqliteConnection`)
110
113
*`-g`: (optional, repeatable) list of columns that are automatically generated by create/update triggers (for example, `created_at`, `updated_at`)
111
-
*`--tsync`: (optional) adds `#[tsync]` attribute to generated structs (see <https://github.com/Wulf/tsync>)
114
+
*`--tsync`: (optional) adds `#[tsync]` attribute to generated structs for the [`tsync` crate](https://github.com/Wulf/tsync)
112
115
*`--model-path`: (optional) set a custom model import path, default `crate::models::`
113
116
*`--schema-path`: (optional) set a custom schema import path, default `crate::schema::`
114
117
*`--no-serde`: (optional) if set, does not output any serde related code
@@ -119,15 +122,15 @@ cargo install dsync
119
122
*`--readonly-prefix`: (optional, repeatable) A prefix to treat a table matching this as readonly*2
120
123
*`--readonly-suffix`: (optional, repeatable) A suffix to treat a table matching this as readonly*2
121
124
*`--diesel-backend`: (when the "advanced-queries" feature is enabled) The diesel backend in use (possible values include `diesel::pg::Pg`, `diesel::sqlite::Sqlite`, `diesel::mysql::Mysql`, or your custom backend type)
122
-
* note: the CLI has fail-safes to prevent accidental file overwriting
123
125
124
126
```sh
125
127
dsync -i src/schema.rs -o src/models
126
128
```
127
129
128
130
Notes:
129
131
130
-
- *2: "readonly" tables dont have `Update*`&`Create*` structs, only `*`(no suffix / prefix) structs.
132
+
- the CLI has fail-safes to prevent accidental file overwriting
133
+
- *2: "readonly" tables dont have `Update*`(`UpdateTodos`) &`Create*`(`CreateTodos`) structs, only `*`(`Todos`, no suffix / prefix) structs.
131
134
For example this is useful for Sqlite views, which are read-only (cannot be written to, but can be read)
132
135
133
136
## Experimental API
@@ -140,7 +143,9 @@ Feel free to open an issue to discuss these API and provide your feeedback.
140
143
141
144
## Docs
142
145
143
-
See `dsync --help` for more information.
146
+
See `dsync --help` for all CLI arguments and documentation.
147
+
148
+
See [docs.rs](https://docs.rs/dsync/latest/dsync/) for library documentation.
144
149
145
150
Feel free to open tickets for support or feature requests.
0 commit comments