Are MongoDB queries client-side operations? Are MongoDB queries client-side operations? mongodb mongodb

Are MongoDB queries client-side operations?


What you are asking here is if MongoDB operations are client-side operations. The short answer is NO.

In MongoDB a query targets a specific collection of documents as mentioned in the documentation and a collection is a group of MongoDB documents which exists within a single database. Collections are simply what tables are in RDBMS. So if query targets a specific collection then it means their are perform on database level, thus server-side. The same thing applies for data modification and aggregation operations.

Sometimes, your operations may involve a client-side processing because MongoDB doesn't provides a way to achieve what you want out of the box. Generally speaking, you only those type of processing when you want to modify your documents structure in the collection or change your fields' type. In such situation, you will need to retrieve your documents, perform your modification using bulk operations.


See the documentation:

Your array is inserted into the existing array as one element. If the array does not exists it is created. If the target is not an array the operation fails.

There is nothing stated like "retriving the element to the client and update it there". So the operation is completely done on the database server side. I don't know any operation that works in the way like you described it. Unless you are chaining a query, with a modify of the item in your client and an update. But these are two separated operations and not one single command.