Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 582fc7e

Browse files
authored
Remove reference to Miniflare#getDurableObjectStorage() (#744)
1 parent 67a6fbd commit 582fc7e

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

docs/src/content/storage/durable-objects.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ const mf = new Miniflare({
3636
## Persistence
3737

3838
By default, Durable Object data is stored in memory. It will persist between
39-
reloads, but not different `Miniflare` instances. To enable
40-
persistence to the file system or Redis, specify the Durable Object persistence
41-
option:
39+
reloads, but not different `Miniflare` instances. To enable persistence to the
40+
file system or Redis, specify the Durable Object persistence option:
4241

4342
```js
4443
const mf = new Miniflare({
@@ -48,7 +47,6 @@ const mf = new Miniflare({
4847
});
4948
```
5049

51-
5250
When using the file system, each object instance will get its own directory
5351
within the Durable Object persistence directory.
5452

@@ -76,13 +74,12 @@ Like the real Workers runtime, Miniflare will throw errors when:
7674

7775
## Manipulating Outside Workers
7876

79-
For testing, it can be useful to put/get data from Durable Object storage
80-
outside a worker. You can do this with the `getDurableObjectNamespace` and
81-
`getDurableObjectStorage` methods.
77+
For testing, it can be useful to make requests to your Durable Objects from
78+
outside a worker. You can do this with the `getDurableObjectNamespace` method.
8279

8380
```js
8481
---
85-
highlight: [32,33,34,35,36,37,38,39,40]
82+
highlight: [28,29,30,31,32]
8683
---
8784
import { Miniflare } from "miniflare";
8885

@@ -97,7 +94,7 @@ const mf = new Miniflare({
9794
9895
async fetch(request) {
9996
const url = new URL(request.url);
100-
if(url.pathname === "/put") await this.storage.put("key", 1);
97+
if (url.pathname === "/put") await this.storage.put("key", 1);
10198
return new Response((await this.storage.get("key")).toString());
10299
}
103100
}
@@ -111,21 +108,14 @@ const mf = new Miniflare({
111108
`,
112109
});
113110

114-
let res = mf.dispatchFetch("http://localhost:8787/put");
115-
console.log(await res.text()); // "1"
116-
117111
const ns = await mf.getDurableObjectNamespace("TEST_OBJECT");
118112
const id = ns.idFromName("test");
119113
const stub = ns.get(id);
120114
const doRes = await stub.fetch("http://localhost:8787/put");
121115
console.log(await doRes.text()); // "1"
122116

123-
const storage = await mf.getDurableObjectStorage(id);
124-
console.log(await storage.get("key")); // 1
125-
await storage.put("key", 2);
126-
127-
res = await mf.dispatchFetch("http://localhost:8787/");
128-
console.log(await res.text()); // "2"
117+
const res = await mf.dispatchFetch("http://localhost:8787/");
118+
console.log(await res.text()); // "1"
129119
```
130120

131121
## Using a Class Exported by Another Script
@@ -172,6 +162,8 @@ export default {
172162

173163
Miniflare can be configured to load `TestObject` from the `api` worker with:
174164

165+
import ConfigTabs from "../components/mdx/config-tabs";
166+
175167
<ConfigTabs>
176168

177169
```toml
@@ -195,14 +187,15 @@ const mf = new Miniflare({
195187
},
196188
modules: true,
197189
scriptPath: "api/src/worker.mjs",
198-
}
199-
]
190+
},
191+
],
200192
});
201193
```
202194

203195
</ConfigTabs>
204196

205-
Workers can access Durable Objects declared in the `workers` field assuming it has a `name` set.
197+
Workers can access Durable Objects declared in the `workers` field assuming it
198+
has a `name` set.
206199

207200
## Internal Details
208201

0 commit comments

Comments
 (0)