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
@@ -52,9 +52,30 @@ By using <GlossaryTooltip term="session">Sessions API</GlossaryTooltip> for read
52
52
53
53
D1 read replication achieves this by attaching a <GlossaryTooltipterm="bookmark">bookmark</GlossaryTooltip> to each write query within a Session. For more information, refer to [Bookmarks](/d1/reference/time-travel/#bookmarks).
54
54
55
-
### Enable read replication
55
+
### Check if read replication is enabled
56
+
57
+
The following code uses REST API to check if read replication is enabled / disabled.
- Set `"mode":"disable"` to disable read replication.
97
+
74
98
If this is your first time using REST API, create an API token. Refer to [Create API token](/fundamentals/api/get-started/create-token/).
75
99
76
100
### Start a D1 Session without constraints
@@ -146,23 +170,23 @@ In this scenario, you want the first request of the page to show a list of all t
146
170
Then, when opening an individual electricity bill statement, we can continue using the same Session by passing the `bookmark` from the first query to subsequent requests. Since each bill statement is immutable, any bill statement listed from the first query is guaranteed to be available in subsequent requests using the same Session.
// NOTE: We achieve sequential consistency with the given `bookmark`.
183
+
constsession=db.withSession(bookmark);
184
+
constresult= (await session
185
+
.prepare('SELECT * FROM bills WHERE accountId = ? AND billId = ? LIMIT 1')
186
+
.bind(accountId, billId)
187
+
.first()) as unknown as Bill;
188
+
189
+
return { bookmark:session.getBookmark() ??'first-unconstrained', bill: result };
166
190
}
167
191
```
168
192
@@ -189,16 +213,99 @@ const result = await session.run()
189
213
190
214
#### Example of using `bookmark`
191
215
216
+
This example follows from [Example of using `first-primary`](/d1/features/read-replication/#example-of-using-first-primary), but retrieves the `bookmark` from HTTP cookie.
192
217
218
+
```ts collapse={1-10, 22-42, 61-86}
219
+
import { ListBillStatementsResult, GetBillStatementResult, Bill } from'./types';
0 commit comments