Skip to content

Instantly share code, notes, and snippets.

@mmckegg
Created March 27, 2013 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmckegg/0d72f7f04610aa9f1467 to your computer and use it in GitHub Desktop.
Save mmckegg/0d72f7f04610aa9f1467 to your computer and use it in GitHub Desktop.
function getPageContext(postId, cb){
var params = { postId: postId }
var result = { currentPage: null, comments: [] }
matchDb.createMatchStream(['post', 'post_comment'], {
params: params,
tail: false
}).on('data', function(data){
if (data.matcher.ref === 'post'){
result.currentPage = data.value
} else if (data.matcher.ref === 'post_comment')
result.comments.push(data.value)
}
}).on('end', function(){
cb(null, result)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment