I am trying to move code related to DB calls outside from my app to database functions. But each time I got an error : TypeError: db.conversations is not a function
.
This is how my function looks like in system.js
table:
function (input) {
var collection = db.collection("conversations");
var query = { conversationNotificationId: input };
return collection.findOne(query);
}
Then I am trying to call it:
db.eval("myFunction('test')")
Here is full error output:
"errmsg" : "TypeError: db.collection is not a function",
What am I doing wrong ?