Skip to content

Commit d24b2ab

Browse files
committed
Iterating on feedback
1 parent bae34ca commit d24b2ab

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/content/docs/durable-objects/reference/data-location.mdx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,41 @@ A [`DurableObjectId`](/durable-objects/api/id) will be logged outside of the spe
1919

2020
:::
2121

22-
Durable Objects can be restricted to a specific jurisdiction by creating a [`DurableObjectNamespace`](/durable-objects/api/namespace/) restricted to a jurisdiction:
22+
Durable Objects can be restricted to a specific jurisdiction by creating a [`DurableObjectNamespace`](/durable-objects/api/namespace/) restricted to a jurisdiction. All [Durable Object ID methods](/durable-objects/api/id/) are valid on IDs within a namespace restricted to a jurisdiction.
2323

2424
```js
2525
const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
2626
const euId = euSubnamespace.newUniqueId();
2727
```
2828

29-
This approach works with all of the [ID methods](/durable-objects/api/id/).
29+
- It is possible to have the same name represent different IDs in different jurisdictions.
30+
- You will run into an error if the jurisdiction on your [`DurableObjectNamespace`](/durable-objects/api/namespace/) and the jurisdiction on [`DurableObjectId`](/durable-objects/api/id) are different.
31+
- You will not run into an error if the [`DurableObjectNamespace`](/durable-objects/api/namespace/) is not associated with a jurisdiction.
32+
33+
```js
34+
const euId1 = env.MY_DURABLE_OBJECT.idFromName("my-name");
35+
const euId2 = env.MY_DURABLE_OBJECT.jurisdiction("eu").idFromName("my-name");
36+
console.assert(!euId1.equal(euId2), "This should always be true");
37+
```
38+
39+
:::caution[Use `DurableObjectNamespace.jurisdiction`]
3040

31-
:::caution[Do not use `newUniqueId(jurisdiction)`]
41+
When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction.
3242

33-
When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction, as explained above.
43+
```js
44+
const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
45+
const euId = euSubnamespace.newUniqueId();
46+
```
3447

3548
Note that it is possible to specify a jurisdiction by creating an individual [`DurableObjectId`](/durable-objects/api/id) restricted to a jurisdiction.
3649

3750
**However, Cloudflare does not recommend this approach.**
3851

39-
This approach is only documented for completeness.
52+
This approach is only shown below for completeness.
4053

4154
```sh
4255
const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" });
4356
```
44-
45-
- As a consequence, it is possible to have the same name represent different IDs in different jurisdictions.
46-
- You will run into an error if the jurisdiction on your [`DurableObjectNamespace`](/durable-objects/api/namespace/) and the jurisdiction on [`DurableObjectId`](/durable-objects/api/id) are different.
47-
- You will not run into an error if the [`DurableObjectNamespace`](/durable-objects/api/namespace/) is not associated with a jurisdiction.
48-
49-
```js
50-
const euId1 = env.MY_DURABLE_OBJECT.idFromName("my-name");
51-
const euId2 = env.MY_DURABLE_OBJECT.jurisdiction("eu").idFromName("my-name");
52-
console.assert(!euId1.equal(euId2), "This should always be true");
53-
```
5457
:::
5558

5659
The common case is that any valid [`DurableObjectId`](/durable-objects/api/id) can be used in the top-level namespace's methods.

0 commit comments

Comments
 (0)