- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 mongodb native 驱动器来获取查询结果的游标。 我正在使用一个“评论”字段,它基本上是一个字符串,下面是我正在使用的代码片段
let leve1_n = 'labreports';
let matchLabReports = { level1_n: "labreports" };
let sortCondition = { _id: 1 };
let projection = {comment : 1 , color: 1, value: 1, value_n: 1, value_d: 1, rangeStart: 1, rangeEnd: 1, level2: 1 };
let collectionName = collectionNames.biomarkerAggregations;
let cursor = dbModule.findCursorSort(dbModule.getDbHandle(dbName), collectionName, matchLabReports, projection,sortCondition);
cursor.forEach(doc => {
// Lambda Expression
// Do something with doc.
})
查找游标排序
function findCursorSort(db, collectionName, query, projection, sortCondition, options) {
if (!errorCheck(db)) {
let cursor = db.collection(collectionName).find(query, projection).sort(sortCondition);
if (!options) {
return cursor;
}
for (let i = 0; i < options.length; i++) {
cursor = cursor.addOption(options[i]);
}
return cursor;
}
}
但这给了我这样的错误......
name: 'MongoError', message: 'Failed to parse: comment: 1. \'comment\' field must be of BSON type string.', ok: 0, errmsg: 'Failed to parse: comment: 1. \'comment\' field must be of BSON type string.', code: 9, codeName: 'FailedToParse' }
从项目中删除评论字段后,一切正常。任何帮助将不胜感激。
最佳答案
在mongodb native driver的collection.js中有一个特性,就是检查哪些字段是query的options,哪些是projection。如果投影中的所有字段都包含评论、限制、排序等字段(写在 testForFields 变量中),则它们将作为选项。
尝试像这样解决这个问题:
原代码:
db.collection(collectionName).find(query, projection)
固定代码:
db.collection(collectionName).find(query).project(projection)
它帮助我解决了问题。
关于javascript - Failed to parse : comment: 1.\'comment\' 字段必须是BSON类型的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44255786/
我试图理解 BSON 符号 来自网站 BSON Site .但是,我无法理解相关性背后的原因。 我也提到了以下问题,但由于以下原因,我不相信。 Question 1 : 不熟悉 ruby 实现 Que
我收到以下错误: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson:
假设我们有一个字符串,里面有二进制 bson 数据。如何加载到 bson object ? 最佳答案 我想在同一个页面上有一个例子可以做到这一点: BSONObjBuilder b; b << "na
我正在寻找如下所示的 type_of 方法: import bson bson.type_of(42) # it should return "int". bson.type_of("hello")
Base64 编码的 BSON 比 BSON 小吗? 最佳答案 Piskvor 的权利,base64 编码的任何东西都比原始长。您对某些内容进行 base64 编码以使其进入具有有限字符轨道的 cha
目前正在做一个 Golang 项目,但我得到了一些 Controller package controller import ( "go.mongodb.org/mongo-driver
这个特定的问题与使用 mongodb 和 golang 包 mongo-driver 相关。 ,但我认为这适用于与 mongodb 的大多数接口(interface)。 使用 Find 时要从集合中查
目前正在做一个 Golang 项目,但我得到了一些 Controller package controller import ( "go.mongodb.org/mongo-driver
可能相关:How to use interface type as a model in mgo (Go)? 我有一个像这样的结构: type Game struct { ID b
有没有一种方法可以使用 MongoDB C++ 驱动程序中的 BSON() 宏来生成 BSON 将空值。例如,为了生成一个 BSON 来表示这个文档:{"a": "foo", "b": null}:
我通过以下两种不同的方法生成了一个 ObjectId: user@ubuntu:~$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
我如何转换 BsonDocument到 FilterDefinition实例? 它是新的 MongoDb C# 驱动程序提供的类。 最佳答案 BsonDocument 和 FilterDefiniti
我正在尝试从 Json 生成 Bson。我尝试使用 Json.Net,但似乎有记录的行为,其中库为整数字段生成 uint64。不幸的是,我们必须使用 uint32。 因此我正在尝试使用 mongodb
我正在使用 https://github.com/mongodb/mongo-go-driver和目前正在尝试实现此类结构的部分更新 type NoteUpdate struct { ID
我目前正在尝试读取 bson 文件以将其导入数据库。我已经可以读取该文件并将其作为字节打印,但最终只收到 bson.errors.InvalidBSON: objsize Too Large 错误。
我尝试在 arch linux 迷你计算机(cubox)上安装 mean.io 堆栈。所以我安装了 nodejs 和 mongodb 包。 我用 Git 检索了堆栈,进行了 npm 安装(没问题)但是
为什么会输出false?我期待 true... package main import ( "fmt" "time" "gopkg.in/mgo.v2/bson" )
这是一种愚蠢的语法错误,尝试了很多方法,但都无法正常工作,请大家帮忙。 使用 mgo 在 Go 中使用 MongoDB,我只是尝试简化 $ne 运算符的使用,代码如下所示,但不断出现编译语法错误: l
我设置了新的 Typescript/React 项目,在 tsconfig.json 文件中收到此错误消息 "找不到 'bson' 的类型定义文件。该文件在程序中,因为:隐式类型库 'bson' 的入
我尝试将数据从 SQL Server 迁移到 MongoDB,但在将数据导入到 MongoDB 的最后阶段遇到了以下类型错误。 mongoImp = dbo.insert_many(jArray)
我是一名优秀的程序员,十分优秀!