Skip to content

Commit bae34ca

Browse files
committed
Iterating over the docs for clarity and better
information segregation
1 parent d373342 commit bae34ca

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,39 @@ const euId = euSubnamespace.newUniqueId();
2828

2929
This approach works with all of the [ID methods](/durable-objects/api/id/).
3030

31-
Methods on a [`DurableObjectNamespace`](/durable-objects/api/namespace/) that take a [`DurableObjectId`](/durable-objects/api/id) as a parameter will throw an exception if the parameter is associated with a different jurisdiction. To achieve this, a [`DurableObjectId`](/durable-objects/api/id) encodes its jurisdiction. As a consequence, it is possible to have the same name represent different IDs in different jurisdictions.
31+
:::caution[Do not use `newUniqueId(jurisdiction)`]
32+
33+
When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction, as explained above.
34+
35+
Note that it is possible to specify a jurisdiction by creating an individual [`DurableObjectId`](/durable-objects/api/id) restricted to a jurisdiction.
36+
37+
**However, Cloudflare does not recommend this approach.**
38+
39+
This approach is only documented for completeness.
40+
41+
```sh
42+
const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" });
43+
```
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.
3248

3349
```js
3450
const euId1 = env.MY_DURABLE_OBJECT.idFromName("my-name");
3551
const euId2 = env.MY_DURABLE_OBJECT.jurisdiction("eu").idFromName("my-name");
3652
console.assert(!euId1.equal(euId2), "This should always be true");
3753
```
38-
However, these methods will not throw an exception if the [`DurableObjectNamespace`](/durable-objects/api/namespace/) is not associated with a jurisdiction. The common case is that any valid [`DurableObjectId`](/durable-objects/api/id) can be used in the top-level namespace's methods.
54+
:::
55+
56+
The common case is that any valid [`DurableObjectId`](/durable-objects/api/id) can be used in the top-level namespace's methods.
3957

4058
```js
4159
const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
4260
const euId = euSubnamespace.idFromName(name);
4361
const stub = env.MY_DURABLE_OBJECT.get(euId);
4462
```
4563

46-
:::caution[Do not use `newUniqueId(jurisdiction)`]
47-
Note that it is possible to specify a jurisdiction by creating an individual [`DurableObjectId`](/durable-objects/api/id) restricted to a jurisdiction:
48-
49-
```sh
50-
const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" });
51-
```
52-
53-
**However, we do not recommend this approach.** Instead, first create a namespace restricted to a jurisdiction, as explained above.
54-
:::
55-
5664
### Supported locations
5765

5866
| Parameter | Location |

0 commit comments

Comments
 (0)