Name: ssb-links
Owner: Secure Scuttlebutt Consortium
Description: null
Created: 2016-02-22 11:56:51.0
Updated: 2018-04-22 01:42:06.0
Pushed: 2018-03-19 22:25:29.0
Homepage: null
Size: 15
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
ssb-plugin that indexes all the links!
if you have a handle on the sbot server:
.use(require('ssb-links')
.links2.read({query: [{$filter: {rel: ['mentions', {$prefix: '@d'}]}}]})
OR if sbot is a client…
s2 = require('ssb-links').init(sbot, {path: '~/.ssb'})
s2.read({query: [{$filter: {rel: ['mentions', {$prefix: '@d'}]}}]})
a leveldb instance will be created at config.path+'/links'
If there is no query provided, a full scan of the links database will be performed. this will return a stream of data that looks like
urce: @{author_of_link},
l: [{rel}, {rel_data}...],
st: @/%/&{link} //the dest can be any type of ssb object.
: {local_timestamp}
this format will be the input to the query.
this module introduces the concept of “rel data”, the rel is now stored as an array, and the data associated with the rel stored with it. by indexing it as an array, it becomes easy to query it when that data is a sortable range (for example, mention names, which may be aphabetically sorted)
see ./links.js
to see how data is mapped.
TODO: map all markdown links, including http links.
the query must be a valid map-filter-reduce
these queries are in JSON format so you can use them via the cli,
sbot links2.read '{QUERY}'
be sure to use single quotes around the query so that the json is property
escaped. otherwise, run these queries by passing them to sbot.links2.read({query: QUERY})
and taking the output as a pull-stream.
returns an stream of {name, feed, uses}
$filter": {
"rel": ["mentions", {"$prefix": "@"}]
,
$reduce":{
"name": ["rel", 1], "feed": "dest", "uses": {"$count": true}
returns feeds in each thread, and how many posts they have made.
return object in form of {[thread_id]:{[poster]:count}}
$filter": {
"rel": ["root"]
,
$reduce":{
"thread": "dest", "participant": "source", "posts": {"$count": true}
$filter": {
"rel": ["mentions", {"$prefix": "@"}],
"dest": "@EMovhfIrFk4NihAKnRNhrfRaqIhBv1Wj8pTxJNgvCCY=.ed25519"
,
$reduce": {
"name": ["rel", 1], "by": "source", "uses": {"$count": true}
MIT