我想要创建一个microblog,每个人都可以阅读所有的帖子,但只有所有者可以删除或编辑这些帖子。在没有sea的gundb中,每个人都可以编辑或删除帖子,在sea( gun.user())中我必须共享公钥,在海上如何获得所有用户的帖子并在时间线上显示帖子?
我怎么能用gundb创建这个呢?
发布于 2019-05-08 21:45:26
每次创建用户时,都可以与所有其他用户共享公钥。(拥有一个维护列表的超级用户)那么你的前端网站将遍历所有的公钥,以获得所有的帖子,并展示他们。这样,人们就可以阅读所有的帖子,而不是编辑。另一种方法是让超级用户运行一个进程,该进程不断地将索引和“复制”帖子放到自己的图表中,然后就可以看到该图形。(使它更受保护)这是非常高层次的答案,但是使用gun.user()和枪核心结构是可能的。
发布于 2019-09-17 09:48:40
我一直在寻找gun中有关数据隐私问题的答案,下面是我的答案:
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
var gun = Gun()gun.user().create('firstMicroblogAuthor', 'somePassword')
gun.user().auth('firstMicroblogAuthor', 'somePassword')var post = {
title: 'First post',
text: 'Hello world!'
}
var author = gun.get('~@firstMicroblogAuthor') // There should be the same `username` in Step 2gun
.user()
.get('posts')
.set(post) // At this step, we saved the post in a user schedule, which by default is only writable by the user
.once(function() {
this.get('author').put(author) // In this step, we link our post with the author (with our user)
gun.get('posts').set(this) // At this step, we save the post with the author installed in the main graph
})gun.user().leave()
gun.user().create('secondMicroblogAuthor', 'somePassword')
gun.user().auth('secondMicroblogAuthor', 'somePassword')
gun
.get('posts') // Read posts from public graph
.once(function() {
this.get('text').put('Goodbye world!') // In this case, we will get an error, because this post was protected
})发布于 2019-07-12 11:01:11
说todo-dapp是公共读用户只写是误导性的,它实际上并没有为您提供查看其他用户文档的能力。
事实上,这是一个长期的恼怒我,实际上没有文件或例子,就如何做到这一点,而当你问发展中国家,你只是面对逃避后。
数据库只有在有一种方法将用户的关注点彼此分离时才会有用。
https://stackoverflow.com/questions/56044288
复制相似问题