node.js query handler for mongodb