|
2 | 2 |
|
3 | 3 | > The dag API comes to replace the `object API`, it supports the creation and manipulation of dag-pb object, as well as other IPLD formats (i.e dag-cbor, ethereum-block, git, etc)
|
4 | 4 |
|
5 |
| -- [`ipfs.dag.put(dagNode, [options])`](#ipfsdagputdagnode-options) |
| 5 | +- [`ipfs.dag.export(cid, [options])`](#ipfsdagexportcid-options) |
6 | 6 | - [Parameters](#parameters)
|
7 | 7 | - [Options](#options)
|
8 | 8 | - [Returns](#returns)
|
9 | 9 | - [Example](#example)
|
10 |
| -- [`ipfs.dag.get(cid, [options])`](#ipfsdaggetcid-options) |
| 10 | +- [`ipfs.dag.put(dagNode, [options])`](#ipfsdagputdagnode-options) |
11 | 11 | - [Parameters](#parameters-1)
|
12 | 12 | - [Options](#options-1)
|
13 | 13 | - [Returns](#returns-1)
|
14 | 14 | - [Example](#example-1)
|
15 |
| -- [`ipfs.dag.tree(cid, [options])`](#ipfsdagtreecid-options) |
| 15 | +- [`ipfs.dag.get(cid, [options])`](#ipfsdaggetcid-options) |
16 | 16 | - [Parameters](#parameters-2)
|
17 | 17 | - [Options](#options-2)
|
18 | 18 | - [Returns](#returns-2)
|
19 | 19 | - [Example](#example-2)
|
20 |
| -- [`ipfs.dag.resolve(ipfsPath, [options])`](#ipfsdagresolveipfspath-options) |
| 20 | +- [`ipfs.dag.import(source, [options])`](#ipfsdagimportsource-options) |
21 | 21 | - [Parameters](#parameters-3)
|
22 | 22 | - [Options](#options-3)
|
23 | 23 | - [Returns](#returns-3)
|
24 | 24 | - [Example](#example-3)
|
| 25 | +- [`ipfs.dag.resolve(ipfsPath, [options])`](#ipfsdagresolveipfspath-options) |
| 26 | + - [Parameters](#parameters-4) |
| 27 | + - [Options](#options-4) |
| 28 | + - [Returns](#returns-4) |
| 29 | + - [Example](#example-4) |
25 | 30 |
|
26 | 31 | _Explore the DAG API through interactive coding challenges in our ProtoSchool tutorials:_
|
27 | 32 | - _[P2P data links with content addressing](https://proto.school/#/basics/) (beginner)_
|
@@ -228,68 +233,6 @@ for await (const result of ipfs.dag.import(fs.createReadStream('./path/to/archiv
|
228 | 233 |
|
229 | 234 | A great source of [examples][] can be found in the tests for this API.
|
230 | 235 |
|
231 |
| -## `ipfs.dag.tree(cid, [options])` |
232 |
| - |
233 |
| -> Enumerate all the entries in a graph |
234 |
| -
|
235 |
| -### Parameters |
236 |
| - |
237 |
| -| Name | Type | Description | |
238 |
| -| ---- | ---- | ----------- | |
239 |
| -| cid | [CID][] | A DAG node that follows one of the supported IPLD formats | |
240 |
| - |
241 |
| -### Options |
242 |
| - |
243 |
| -An optional object which may have the following keys: |
244 |
| - |
245 |
| -| Name | Type | Default | Description | |
246 |
| -| ---- | ---- | ------- | ----------- | |
247 |
| -| path | `String` | An optional path within the DAG to resolve | |
248 |
| -| recursive | `boolean` | `false` | If set to true, it will follow the links and continuously run tree on them, returning all the paths in the graph | |
249 |
| -| timeout | `Number` | `undefined` | A timeout in ms | |
250 |
| -| signal | [AbortSignal][] | `undefined` | Can be used to cancel any long running requests started as a result of this call | |
251 |
| - |
252 |
| -### Returns |
253 |
| - |
254 |
| -| Type | Description | |
255 |
| -| -------- | -------- | |
256 |
| -| `Promise<Array>` | An array with the paths passed | |
257 |
| - |
258 |
| -### Example |
259 |
| - |
260 |
| -```JavaScript |
261 |
| -// example obj |
262 |
| -const obj = { |
263 |
| - a: 1, |
264 |
| - b: [1, 2, 3], |
265 |
| - c: { |
266 |
| - ca: [5, 6, 7], |
267 |
| - cb: 'foo' |
268 |
| - } |
269 |
| -} |
270 |
| - |
271 |
| -const cid = await ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha2-256' }) |
272 |
| -console.log(cid.toString()) |
273 |
| -// zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5 |
274 |
| - |
275 |
| -const result = await ipfs.dag.tree('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5') |
276 |
| -console.log(result) |
277 |
| -// Logs: |
278 |
| -// a |
279 |
| -// b |
280 |
| -// b/0 |
281 |
| -// b/1 |
282 |
| -// b/2 |
283 |
| -// c |
284 |
| -// c/ca |
285 |
| -// c/ca/0 |
286 |
| -// c/ca/1 |
287 |
| -// c/ca/2 |
288 |
| -// c/cb |
289 |
| -``` |
290 |
| - |
291 |
| -A great source of [examples][] can be found in the tests for this API. |
292 |
| - |
293 | 236 | ## `ipfs.dag.resolve(ipfsPath, [options])`
|
294 | 237 |
|
295 | 238 | > Returns the CID and remaining path of the node at the end of the passed IPFS path
|
|
0 commit comments