Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

module.exports = {
description: 'full text search within ssb messages',
commands: {
query: {
type: 'source',
description: 'perform a search query'
args: {
query: 'search terms, space separated'
}
}
}
}
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ var msgs = require('ssb-msgs')

exports.name = 'search'
exports.version = '2.0.0'
exports.manifest = { query: 'source' }
exports.manifest = { query: 'source', help: 'sync' }

function isString (s) {
return 'string' === typeof s
}

exports.init = function (sbot) {
var search = sbot._flumeUse('search', FlumeViewSearch(13, 3, function (data) {
Expand All @@ -14,12 +18,14 @@ exports.init = function (sbot) {
return {
query: function (opts) {
opts = opts || {}

if(!isString(opts.query)) return pull.values([])
console.error('search:', opts)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental log?

return pullCont(function (cb) {
var keys = {}
pull(
search.query({query: opts.query}),
pull.drain(function (data) {
console.log('found:', data.key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental log?

keys[data.key] = data.value
}, function () {
var counts = {}
Expand All @@ -46,14 +52,8 @@ exports.init = function (sbot) {
})
)
})
}
},
help: function () { return require('./help') }
}
}