user3949359
user3949359

Reputation:

Why use the nodeJS driver to manipulate a MongoDB database?

What's the point of using the driver and JavaScript if we can perform the same query operations a lot easier from the Mongo shell?

Upvotes: 1

Views: 107

Answers (2)

alandarev
alandarev

Reputation: 8635

In theory any piece of code can as well be achieved through a good shell.

So, why we actually stay away from shell at all cost?

  1. Security concerns, when an application uses shell to perform operations, it is very sensitive to exploits.
  2. Configuration. What if server does not have the needed client, or the client is of a wrong version?
  3. Driver handles many edge cases you might not notice at first glance. Connection loss handling, multiple connections, and such.

Briefly, imagine shell command as a User Interface for administrators. It might be powerful enough for a task, but being a developer you would like to pass this middle-man and communicate directly with the server.

Upvotes: 1

peter.petrov
peter.petrov

Reputation: 39477

If you program in a certain language (say Java), it's much easier to use the Java driver to access MongoDB rather call the mongodb shell from Java, and execute commands to MongoDB this way (from the shell). The same applies for the JavaScript language and the NodeJS JavaScript host environment in particular. That's why using a driver makes sense.

Actually this whole thing applies not just to MongoDB but to relational databases too (like MySQL, Oracle, etc.).

Upvotes: 1

Related Questions