简体   繁体   English

查询数据时应使用MongoTemplate还是DBCollection

[英]Should i use MongoTemplate or DBCollection when query data

[Java Spring] At the moment, I'm using MongoTemplate to query data [Java Spring]目前,我正在使用MongoTemplate查询数据

  1. MongoTemplate --> return List MongoTemplate->返回列表

    mongoTemplate.find(query, entity) mongoTemplate.find(查询,实体)

  2. DbCollection --> return DbCursor DbCollection->返回DbCursor

    dbCollection.find() dbCollection.find()

Then what should i use to best way 那我应该怎么用最好的方法

since your application is a spring application i would suggest to stick with mongotemplate as it is springframework provided class and can go along well with other spring features. 由于您的应用程序是spring应用程序,因此我建议您坚持使用mongotemplate,因为它是springframework提供的类,并且可以与其他spring功能一起使用。 whereas DBcollection is a class from mongo API for java and there might be some cases where you have to play around to get your stuff done. 而DBcollection是mongo API for Java中的一个类,在某些情况下,您可能需要花很多时间才能完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM