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
45 changes: 45 additions & 0 deletions help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var Query = {
type: 'JSONString',
description: 'the query it self. It should be the format of a map-filter-reduce query',
optional: false
}
module.exports = {
description: 'query ssb database with map-filter-reduce queries',
commands: {
read: {
type: 'source',
description: 'perform a query',
args: {
query: Query,
limit: {
type: 'number',
description: 'number of items to return',
optional: true
},
reverse: {
type: 'boolean',
description: 'reverse order of output',
optional: true,
},
live: {
type: 'boolean',
description: 'include real time output',
optional: true,
},
old: {
type: 'boolean',
description: 'include old output, defaults to true',
optional: true
}
}
},
explain: {
type: 'sync',
description: 'return object describing indexes ssb-query will use for this query, useful for debugging performance problems'
args: {
query: Query
}
}
}
}

8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ exports.name = 'query'
exports.version = require('./package.json').version
exports.manifest = {
read: 'source',
explain: 'sync'
explain: 'sync',
help: 'sync'
}

//what are links used for?
Expand All @@ -35,7 +36,7 @@ var indexes = [
]

function mapRts (msg) {
msg.rts = Math.min(msg.timestamp, msg.value.timestamp)
msg.rts = Math.min(msg.timestamp, msg.value.timestamp) || msg.timestamp
return msg
}

Expand Down Expand Up @@ -67,7 +68,8 @@ exports.init = function (ssb, config) {
opts.query = JSON.parse(opts.query)
return read(opts)
}

s.help = function () { return require('./help') }
return s
}