hirosystems / stacks.js

JavaScript libraries for identity, auth, storage and transactions on the Stacks blockchain.
https://stacks.js.org
MIT License
947 stars 308 forks source link

storage documentation / advice #248

Closed alidcast closed 7 years ago

alidcast commented 7 years ago

This is semi-related to #246 about stabilizing more file operations.

With only putFile and getFile right now, how should storage be handled when 1) you need to access user specific data and 2) you need to access data for all users?

I've tried to look at other open-source Blockstack apps. Beacon seems to be in its early development or at least its changes are not public. Guild seems to be saving all the data in one file and iterating to find that of the correct user data (see here for source), but, unless I'm misunderstanding how storage works, this doesn't seem like an approach that will scale well.

I'll hack together an approach in the meantime but would prefer to know the proper way of handling storage. Thanks!

shea256 commented 7 years ago

@alidcastano Hey thanks for starting this issue.

Can you explain what you mean by "access user specific data"? Do you mean that you have a central server and you want the locally stored data to be relayed back to your central server? Or do you mean that you have user A's data that needs to be seen by user B?

Regarding "access data for all users", can you elaborate on your use case? For fully decentralized apps this isn't possible because there is no central server or "mothership". That said, you can always include a call where user data is copied and synced to a central server. Highly depends on what you're trying to do.

Our ideal model for applications here is that we can eliminate the need for central servers at all. So apps like marketplaces and social networks need to be rethought. Very different approach and very different way of thinking.

Would love to know what app you're building. Happy to provide further guidance.

alidcast commented 7 years ago

@shea256 Thanks for the quick response.

Based on your response, I likely need to rethink my approach which is anchored on a central server way of thinking about storage.

I'm experimenting with a social note-taking app. The closest equivalent would be Quizlet.

So the basic functionality would be:

And vice-versa.

What's the recommended way of handling this via only putFile and getFile?

Related question: so when you do puFile, user A's data is first being stored with all the other users' data in a decentralized fashion, then only user A's data is synced to a central location (e.g. his or hers Dropbox account)?