【问题标题】:what is the difference between MongoClient and MongoConnectionMongoClient 和 MongoConnection 有什么区别
【发布时间】:2015-08-13 06:48:47
【问题描述】:

我想知道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 

请解释一下有什么区别

【问题讨论】:

  • 没有区别。只有“client”变量变为“con”变量。

标签: mongodb scala casbah scala-2.11


【解决方案1】:

MongoConnection 已被弃用,取而代之的是 MongoClient。据我所知,在引入 MongoClient 时并没有什么不同。我猜随着时间的推移,功能可能会有所不同。

来自 API 教程:Casbah API tutorial

"2.10的Java驱动中默认添加了MongoClient MongoDB 的连接类。旧的 Casbah 代码可以使用 应该更新 MongoConnection 以使用 MongoClient。”

【讨论】:

    猜你喜欢
    • 2010-10-02
    • 2011-12-12
    • 2010-09-16
    • 2012-03-14
    • 2012-02-06
    • 2011-02-25
    • 2011-11-22
    • 2015-03-26
    • 2013-08-19
    相关资源
    最近更新 更多