MongoClient和MongoConnection之间有什么区别

时间:2015-08-13 06:48:48

标签: mongodb scala casbah scala-2.11

我想知道mongoClientmongoConnection之间有什么区别,这两个代码之间的区别是什么

  serverAddress=new ServerAddress("Localhost",27017)
           client= MongoClient(serverAddress)
           testDB = client("testdb")//get database Name
           collection = testDB("mycol")//get collection Name 

 serverAddress=new ServerAddress("Localhost",27017)
           con= MongoClient(serverAddress)
           testDB = con("testdb")//get database Name
           myCollection = testDB("mycol")//get collection Name 

请解释有什么区别

1 个答案:

答案 0 :(得分:1)

MongoConnection已被弃用,有利于MongoClient。据我所知,MongoClient推出时没有任何区别。我想功能可能会随着时间的推移发生变化。

来自API教程:Casbah API tutorial

  

“MongoClient已添加到2.10中的Java驱动程序中作为默认值   MongoDB的连接类。较旧的Casbah代码可能会使用   应该更新MongoConnection以使用MongoClient。“

相关问题