当前位置: 首页 > 知识库问答 >
问题:

mongo-scala-driver:获取结果

张丁雷
2023-03-14

我在MongoDB中有以下文档:

{ "index_column" : "site_id", "mapped_column":"site_name"}

我正在使用scala代码中的mongo-scala-driver来查询服务器。如何将mapped_column转换为scala字符串变量?我尝试使用以下代码:

val result = mongocollection.find(equal("index_column", data)).first()

共有1个答案

徐高懿
2023-03-14

我通过将驱动程序切换到mongodb casbah来解决这个问题,它可以通过以下代码来完成:

val result = mongocollection.find(MongoDBObject("index_column"-> "site_id")).one()

println(result.get("mapped_column"))
 类似资料:
  • mongo-scala-driver 是 MongoDB 的 Scala 客户端开发包。

  • 有人能提供链接或代码片段吗? 附注:在官方mongodb站点中有同步事务示例,但我需要在Scala中的异步、非阻塞事务示例。

  • 我试图用Scala打印MongoDB查询的结果 尝试使用以下方法手动打印: 产生了以下信息: 信息:ReadPreferenceServerSelector{ReadPreference=Primary}没有从群集描述中选择服务器ClusterDescription{type=Unknown,ConnectionMode=Single,ServerDescriptions=[ServerDescr

  • END OF LIFE NOTICE Version v2.2.0 was the final feature release of the MongoDB Perl driver andversion v2.2.2 is the final patch release. As of August 13, 2020, the MongoDB Perl driver and related libr

  • mongo-d-driver 是 MongoDB 的 D 语言开发包。 示例代码: /** make: dmd -version=D2 -Iexport libmongod-D2.a example/connect.d** -Iexport : path to the folder containing the files: * bson.di, bson_h.di, md5.di, mongo.

  • mongo-matlab-driver 是 MongoDB 的 Matlab 驱动开发包。