Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 166d341

Browse files
committed
docs: update api docs
1 parent 31bddd4 commit 166d341

File tree

1 file changed

+9
-66
lines changed

1 file changed

+9
-66
lines changed

docs/core-api/DAG.md

+9-66
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,31 @@
22

33
> 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)
44
5-
- [`ipfs.dag.put(dagNode, [options])`](#ipfsdagputdagnode-options)
5+
- [`ipfs.dag.export(cid, [options])`](#ipfsdagexportcid-options)
66
- [Parameters](#parameters)
77
- [Options](#options)
88
- [Returns](#returns)
99
- [Example](#example)
10-
- [`ipfs.dag.get(cid, [options])`](#ipfsdaggetcid-options)
10+
- [`ipfs.dag.put(dagNode, [options])`](#ipfsdagputdagnode-options)
1111
- [Parameters](#parameters-1)
1212
- [Options](#options-1)
1313
- [Returns](#returns-1)
1414
- [Example](#example-1)
15-
- [`ipfs.dag.tree(cid, [options])`](#ipfsdagtreecid-options)
15+
- [`ipfs.dag.get(cid, [options])`](#ipfsdaggetcid-options)
1616
- [Parameters](#parameters-2)
1717
- [Options](#options-2)
1818
- [Returns](#returns-2)
1919
- [Example](#example-2)
20-
- [`ipfs.dag.resolve(ipfsPath, [options])`](#ipfsdagresolveipfspath-options)
20+
- [`ipfs.dag.import(source, [options])`](#ipfsdagimportsource-options)
2121
- [Parameters](#parameters-3)
2222
- [Options](#options-3)
2323
- [Returns](#returns-3)
2424
- [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)
2530

2631
_Explore the DAG API through interactive coding challenges in our ProtoSchool tutorials:_
2732
- _[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
228233

229234
A great source of [examples][] can be found in the tests for this API.
230235

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-
293236
## `ipfs.dag.resolve(ipfsPath, [options])`
294237

295238
> Returns the CID and remaining path of the node at the end of the passed IPFS path

0 commit comments

Comments
 (0)