revolt
revolt

Reputation: 31

Mongo Java Driver api vs Spring data mongo for aggregation

I am new to mongo and writing aggregation queries in java but, I am confused which way to use i.e. either using mongo java driver api or spring data mongo classes?

Upvotes: 2

Views: 2498

Answers (2)

Attila Gróf
Attila Gróf

Reputation: 81

If you want to quickly reach a state where you can query, insert and use other operations then I would recommend Spring data because it has a nice layer over the Mongo driver.

If you are very heavily dependent on performance and custom usages of Mongo then I would use the mongo driver.

Don't forget that the more abstraction layer you application has, the bigger and slower it will get. On the other hand using these abstraction layers development time can be reduced significantly.

In your case I would recommend Spring data, it is an easier start, if you get familiar with it you can dive deeper into the Mongo driver.

Upvotes: 2

Mark B
Mark B

Reputation: 201088

There's no rule that says you need to use one versus the other. Pick which ever one fits with your application architecture the best. Spring Data MongoDB is an abstraction on top of the Mongo Java Driver, so you might think of the driver as a more low-level, direct access to your database. If you are already using Spring in your application then it will likely make sense to use Spring Data MongoDB.

Upvotes: 2

Related Questions