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
+22-5Lines changed: 22 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,12 +52,12 @@ let database = try DB(path: "...")
52
52
let todos =tryawait database.todoQueries.selectTodos.execute()
53
53
54
54
for todo in todos {
55
-
print(todo.id, todo.name, todo.completedOn)
55
+
print(todo.id, todo.name, todo.completedOn)
56
56
}
57
57
58
58
// Easily observe any query as the database changes.
59
59
fortryawait todos in database.todoQueries.selectTodos.observe() {
60
-
print("Got todos", todos)
60
+
print("Got todos", todos)
61
61
}
62
62
```
63
63
@@ -66,7 +66,7 @@ No need to wrap your database in repositories. Just pass in the `any <Name>Query
66
66
you can pass in `Queries.Just`, `Queries.Fail` or even `Queries.Test` for call counts.
67
67
```swift
68
68
classViewModel {
69
-
let selectTodos: any SelectTodosQuery
69
+
let selectTodos: any SelectTodosQuery
70
70
}
71
71
72
72
let live =ViewModel(selectTodos: db.todoQueries.selectTodos)
@@ -101,7 +101,7 @@ func main() async throws {
101
101
let todos =tryawait database.selectTodos.execute()
102
102
103
103
for todo in todos {
104
-
print(todo.id, todo.name, todo.completedOn)
104
+
print(todo.id, todo.name, todo.completedOn)
105
105
}
106
106
}
107
107
```
@@ -193,6 +193,13 @@ puresql init
193
193
194
194
### Adding Your First Migration
195
195
The build tool will error if it is unable to find the `/Migrations` folder defined in the `puresql.yaml` file. Make sure the folder exists and add your first migration `0.sql`.
196
+
197
+
For clarity your migrations at this point should have the structure:
198
+
```
199
+
Migrations/
200
+
0.sql
201
+
```
202
+
196
203
When a new migration is needed, you can simply add a new file with a number 1 higher than the previous. To automatically do this the cli tool can do it for you by running
197
204
```
198
205
puresql migrations add
@@ -231,7 +238,17 @@ let database = try DB(config: config)
231
238
```
232
239
233
240
# Queries
234
-
All queries will be stored in the `/Queries` directory. More than one query can go in each file. To get started, create a new file in the `/Queries` directory. The cli can do this automatically. In the same directory where `init` was run, execute
241
+
All queries will be stored in the `/Queries` directory. More than one query can go in each file. To get started, create a new file in the `/Queries` directory.
242
+
243
+
For example:
244
+
```
245
+
Migrations/
246
+
0.sql
247
+
Queries/
248
+
Todo.sql
249
+
```
250
+
251
+
The cli can do this automatically. In the same directory where `init` was run, execute
0 commit comments