Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Examples of connecting js-ipld to a local IPFS node? #295

Closed
cyphercider opened this issue Feb 25, 2021 · 4 comments
Closed

Examples of connecting js-ipld to a local IPFS node? #295

cyphercider opened this issue Feb 25, 2021 · 4 comments

Comments

@cyphercider
Copy link

Hi, thanks for this library! I am trying to get started with IPLD, basic reading and writing to the network.... Is there a code sample that shows how to connect to a local node, write data, and read data? Also, is there a way to set up IPLD schemas to constrain the shape of the objects being written?

@vmx
Copy link
Member

vmx commented Feb 25, 2021

Hi @jeffkhull. The JavaScript implementation of IPLD encountered a lot of changes over the past year and we are moving towards smaller building blocks that concentrate on the core of IPLD, e.g. codecs. The "new hot stuff" is currently here: https://github.com/multiformats/js-multiformats

You would then use those building blocks and assemble them as you need. In your case it could be something like you use js-multiformats to encode your data and then use the IPFS Block API to actually store it in IPFS.

In regards to IPLD Schema validation, your best bet is https://github.com/rvagg/js-ipld-schema-validator, though I don't know how up to date it is (it worked for me last time I used it though).

I currently work on getting js-ipfs-unixfs to use the new js-multiformats stuff, so for you it might be helpful at looking at the code changes (especially the tests) I've done here: ipfs/js-ipfs-unixfs#116

@cyphercider
Copy link
Author

cyphercider commented Mar 2, 2021

Hey @vmx , thanks for the above info. I have been researching and trying out various libraries for a "simple" way to interact with IPFS using ipld schemas, and so far a combination of ipfs-http-client and ipld-schema seems to do the trick, at least for immutable data.

The next challenge I need to figure out is how to allow "entities" in the linked data graph to be mutable. So that people can edit entity content like wikipedia, and add links to other entities, I think I need mutability. However, I have no idea how to do this. I see "mutable filesystem (MFS)" on the IPFS docs pages, but I'm not sure if this is the right solution or not. As you are of course much more familiar with these technologies than I am, I was wondering if you might point me in the right direction for libraries I can use to mutate nodes in a linked data graph, yet preserve links to other data?

@vmx
Copy link
Member

vmx commented Mar 2, 2021

@jeffkhull you can decode the blocks, manipulate the decoded data manually (directly in JS) and then encode and store them again.

Though, is what you are asking for about also updating blocks that depend of each other? Let's say you have a link from block A to block B. Now you manipulate block B, let's call the manipulated one C. Of course the CID of B and C is different. Do you now want block A to automatically point to C?

@cyphercider
Copy link
Author

Hey @vmx, yes exactly, A would need to then automatically point to C. I was just reading about IPNS... would using IPNS to resolve entities be the answer?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants