I just installed Robo3T( previously named robomongo), which has a GUI for mongo db. I want to add a custom function to help me get the last N documents in normal order, the query statement is like this:
db.getCollection('i1801').find().skip(db.getCollection('i1801').count() - 1200)
And I found from stackoverflow(mongodb: how to get the last N records?), this can be written as a function like this:
function last(N) {
return db.collection.find().skip(db.collection.count() - N);
}
And I go back to my Robo3T, trying to add a custom function last()
, but didn't work, nothing showed up under function tab.
I have attached some screen captures illustrating this issue:
After I clicked save button, nothing happened, still no functions under function tab. And the log shows function last
created, and function tab being refreshed.
So, how can I add a last
function here?