Create Processes stored in MongoDB [closed]

0

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?

    
asked by Fatima Reyes 22.09.2017 в 20:49
source

1 answer

0

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

    
answered by 22.09.2017 / 21:22
source