MongoCollection与DBCollection java [英] MongoCollection versus DBCollection java

查看:123
本文介绍了MongoCollection与DBCollection java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你什么时候应该使用MongoCollection和DBCollection?
同样的问题适用于DBObject,BasicDBObject,Document。似乎有不同的东西是相似的。至少对我来说他们是。我觉得这很令人困惑。任何建议都会非常受欢迎。

When should you be using MongoCollection and when DBCollection? The same questions apply to DBObject, BasicDBObject, Document. There seem to be different things are similar. At least to me they are. I find this very confusing. Any advice would be very welcome.

推荐答案

这似乎是关于3.0.0 MongoDB Java驱动程序的问题。

This seems to be a question about the 3.0.0 MongoDB Java driver.

一般建议是使用Document / MongoCollection / MongoDatabase进行新的应用程序开发。

The general advice is to use Document/MongoCollection/MongoDatabase for new application development.

然而,DBObject / DBCollection / DB类保留在3.0中.0驱动程序,以便当前使用2.x驱动程序系列的许多现有应用程序具有3.0驱动程序的升级路径。驱动程序作者(我是其中之一)试图通过弃用MongoClient.getDB方法来明确这一点,该方法返回数据库类的实例,以鼓励使用新的MongoClient.getDatabase方法,该方法返回一个实例MongoDatabase。

The DBObject/DBCollection/DB classes, however, remain in the 3.0.0 driver so that many existing applications that currently use the 2.x driver series have an upgrade path to the 3.0 driver. The driver authors (I'm one of them) tried to make this clear by deprecating the MongoClient.getDB method, which returns an instance of the DB class, in order to encourage use of the new MongoClient.getDatabase method, which returns an instance of MongoDatabase.

这篇关于MongoCollection与DBCollection java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆