Skip to content

Commit 127d0ad

Browse files
committed
Turning code blocks into in-line code, restructure
1 parent d24b2ab commit 127d0ad

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,32 @@ const euId = euSubnamespace.newUniqueId();
2727
```
2828

2929
- 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.
3230

3331
```js
3432
const euId1 = env.MY_DURABLE_OBJECT.idFromName("my-name");
3533
const euId2 = env.MY_DURABLE_OBJECT.jurisdiction("eu").idFromName("my-name");
3634
console.assert(!euId1.equal(euId2), "This should always be true");
3735
```
3836

39-
:::caution[Use `DurableObjectNamespace.jurisdiction`]
40-
41-
When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction.
37+
- 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.
38+
- You will not run into an error if the [`DurableObjectNamespace`](/durable-objects/api/namespace/) is not associated with a jurisdiction.
39+
- All [Durable Object ID methods](/durable-objects/api/id/) are valid on IDs within a namespace restricted to a jurisdiction.
4240

43-
```js
44-
const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
45-
const euId = euSubnamespace.newUniqueId();
46-
```
41+
```js
42+
const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
43+
const euId = euSubnamespace.idFromName(name);
44+
const stub = env.MY_DURABLE_OBJECT.get(euId);
45+
```
4746

48-
Note that it is possible to specify a jurisdiction by creating an individual [`DurableObjectId`](/durable-objects/api/id) restricted to a jurisdiction.
47+
:::caution[Use `DurableObjectNamespace.jurisdiction`]
4948

50-
**However, Cloudflare does not recommend this approach.**
49+
When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction, using `const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu")`.
5150

52-
This approach is only shown below for completeness.
51+
Note that it is also possible to specify a jurisdiction by creating an individual [`DurableObjectId`](/durable-objects/api/id) restricted to a jurisdiction, using `const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" })`.
5352

54-
```sh
55-
const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" });
56-
```
53+
**However, Cloudflare does not recommend this approach.**
5754
:::
5855

59-
The common case is that any valid [`DurableObjectId`](/durable-objects/api/id) can be used in the top-level namespace's methods.
60-
61-
```js
62-
const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
63-
const euId = euSubnamespace.idFromName(name);
64-
const stub = env.MY_DURABLE_OBJECT.get(euId);
65-
```
66-
6756
### Supported locations
6857

6958
| Parameter | Location |

0 commit comments

Comments
 (0)