This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 4 files changed +11
-22
lines changed
examples/traverse-ipld-graphs
interface-ipfs-core/src/dag
ipfs-core/src/components/dag 4 files changed +11
-22
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,13 @@ async function main () {
15
15
const cid = await ipfs . dag . put ( myData , { format : 'dag-cbor' , hashAlg : 'sha2-256' } )
16
16
let result
17
17
18
- result = await ipfs . dag . get ( cid , 'name' )
18
+ result = await ipfs . dag . get ( cid , { path : 'name' } )
19
19
console . log ( result . value )
20
20
21
- result = await ipfs . dag . get ( cid , 'likes' )
21
+ result = await ipfs . dag . get ( cid , { path : 'likes' } )
22
22
console . log ( result . value )
23
23
24
- result = await ipfs . dag . get ( cid + '/likes/0' )
24
+ result = await ipfs . dag . get ( cid , { path : '/likes/0' } )
25
25
console . log ( result . value )
26
26
}
27
27
Original file line number Diff line number Diff line change @@ -56,11 +56,11 @@ async function main () {
56
56
console . log ( result . value )
57
57
}
58
58
59
- await logResult ( ( ) => ipfs . dag . get ( v1tag + '/' ) , 'Tag object:' )
60
- await logResult ( ( ) => ipfs . dag . get ( v1tag + '/object/message' ) , 'Tagged commit message:' )
61
- await logResult ( ( ) => ipfs . dag . get ( v1tag + '/object/parents/0/message' ) , 'Parent of tagged commit:' )
62
- await logResult ( ( ) => ipfs . dag . get ( v1tag + '/object/tree/src/hash/hello/hash' ) , '/src/hello file:' )
63
- await logResult ( ( ) => ipfs . dag . get ( v1tag + '/object/parents/0/tree/src/hash/hello/hash' ) , 'previous version of /src/hello file:' )
59
+ await logResult ( ( ) => ipfs . dag . get ( v1tag ) , 'Tag object:' )
60
+ await logResult ( ( ) => ipfs . dag . get ( v1tag , { path : '/object/message' } ) , 'Tagged commit message:' )
61
+ await logResult ( ( ) => ipfs . dag . get ( v1tag , { path : '/object/parents/0/message' } ) , 'Parent of tagged commit:' )
62
+ await logResult ( ( ) => ipfs . dag . get ( v1tag , { path : '/object/tree/src/hash/hello/hash' } ) , '/src/hello file:' )
63
+ await logResult ( ( ) => ipfs . dag . get ( v1tag , { path : '/object/parents/0/tree/src/hash/hello/hash' } ) , 'previous version of /src/hello file:' )
64
64
}
65
65
66
66
main ( )
Original file line number Diff line number Diff line change @@ -146,10 +146,8 @@ module.exports = (common, options) => {
146
146
expect ( cid ) . to . eql ( cidCbor )
147
147
} )
148
148
149
- it ( 'should get by CID string + path' , async function ( ) {
150
- const cidCborStr = cidCbor . toBaseEncodedString ( )
151
-
152
- const result = await ipfs . dag . get ( cidCborStr + '/pb/Data' )
149
+ it ( 'should get by CID with path option' , async function ( ) {
150
+ const result = await ipfs . dag . get ( cidCbor , { path : '/pb/Data' } )
153
151
expect ( result . value ) . to . eql ( uint8ArrayFromString ( 'I am inside a Protobuf' ) )
154
152
} )
155
153
Original file line number Diff line number Diff line change @@ -14,16 +14,7 @@ module.exports = ({ ipld, preload }) => {
14
14
/**
15
15
* @type {import('ipfs-core-types/src/dag').API["get"] }
16
16
*/
17
- const get = async function get ( ipfsPath , options = { } ) {
18
- const {
19
- cid,
20
- path
21
- } = toCidAndPath ( ipfsPath )
22
-
23
- if ( path ) {
24
- options . path = path
25
- }
26
-
17
+ const get = async function get ( cid , options = { } ) {
27
18
if ( options . preload !== false ) {
28
19
preload ( cid )
29
20
}
You can’t perform that action at this time.
0 commit comments