I come with my next question, is it possible to create processes stored in MongoDb or an alternative to speed up a query with a large amount of data in a Mongodb database?
I come with my next question, is it possible to create processes stored in MongoDb or an alternative to speed up a query with a large amount of data in a Mongodb database?
MongoDB has no stored procedures, although it has a similar function: we can store functions within the database. An example:
db.system.js.save(
{
_id:"findLast10",
value: function(){
return db.people.find
(
{},
{name:1}
).sort({name:-1}).limit(10).pretty().toArray();
}
});
If you execute the previous code in the console, you will be saving a JavaScript function in the database, find it actually returns a cursor, you have to add the < strong> toArray to return the results, instead of the cursor itself.
You can review Here some tricks for MongoBB