Files: 6dde1c5e1d32a7427848bfad8a4641577bd0d1ab / indexes / feed.js
837 bytesRaw
1 | var Follower = require('../follower') |
2 | var pull = require('pull-stream') |
3 | var path = require('path') |
4 | var ltgt = require('ltgt') |
5 | var u = require('../util') |
6 | |
7 | module.exports = function (db) { |
8 | |
9 | var indexPath = path.join(db.location, 'feed') |
10 | var index = Follower(db, indexPath, 1, function (data) { |
11 | if(data.sync) return |
12 | return { |
13 | key: [data.value.timestamp, data.value.author], |
14 | value: data.key, type: 'put' |
15 | } |
16 | }) |
17 | |
18 | index.createFeedStream = function (opts) { |
19 | opts = u.options(opts) |
20 | //mutates opts |
21 | ltgt.toLtgt(opts, opts, function (value) { |
22 | return [value, u.lo] |
23 | }, u.lo, u.hi) |
24 | |
25 | var _keys = opts.keys |
26 | var _values = opts.values |
27 | opts.keys = false |
28 | opts.values = true |
29 | |
30 | return pull( |
31 | index.read(opts), |
32 | db.lookup(_keys, _values) //XXX |
33 | ) |
34 | } |
35 | |
36 | return index |
37 | |
38 | } |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 |
Built with git-ssb-web