-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of getting messages with blobs #301
Comments
You could use jitdb's |
The fullMentions example in the readme is like this: sbot.db.query(
where(and(type('post'), fullMentions(alice.id)))),
toCallback((err, msgs) => {
console.log('There are ' + msgs.length + ' messages')
sbot.close()
})
) But it can filter just based on the prefix of the string that you pass to it also? |
As I said, you will have to add more code to the source code at |
thanks @staltz
So something that is not totally clear to me about the new DB — The thing I want to avoid is my server having to re-process the same messages each time you restart the server. It sounds like for that you would need to create some kind of plugin that stores its last state on the hard drive. Is that right? |
Jitdb doesn't re-process old messages upon restarting, because jitdb indexes are persisted to disk. |
thanks @staltz It's a little bit unclear how the // The `seekType` function takes a buffer and uses `bipf` APIs to search for
// the fields we want.
const bValue = Buffer.from('value') // better for performance if defined outside
const bContent = Buffer.from('content')
const bType = Buffer.from('type')
function seekBlob(buffer) {
var p = 0 // p stands for "position" in the buffer, offset from start
p = bipf.seekKey(buffer, p, bValue)
if (p < 0) return
p = bipf.seekKey(buffer, p, bContent)
if (p < 0) return
return bipf.seekKey(buffer, p, bType)
}
sbot.db.query(
where(
and(
type('post'),
predicate(seekBlob, arg => { // what is passed to this function?
console.log('***arg***', arg)
}, { name: 'blobs' })
)
),
descending(),
paginate(10),
toCallback((err, res) => {
if (err) return console.log('arrrrr', err)
console.log('res', res)
})
) The predicate fn has a signature like We want to gossip blobs in this case along with the messages. |
@nichoth these things are in the docs (readme) for jitdb already. See again:
|
If we travel back in time,
ssb-server
includes this example:How would you do the same thing in ssb-db2? "monitor the feed for new links to blobs"?
The text was updated successfully, but these errors were encountered: