- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个日期字段作为 NumberLong 存储在 mongo 集合中
此集合上日期字段 {$gte: NumberLong("635186135151387725")} 的 Node 查询是尽管在 mongoshell 中同样有效,但没有提取任何记录。
我尝试使用 require('mongodb').Long 和查询作为
{$gte: Long.fromString("635186135151387725",10)} 但没有用。
还尝试了模块“node-int64”、“int64-native”,但没有成功。
是否有 Node 模块可以拯救?
最佳答案
这对我来说很好,也许你的查询没有正确发出。以下面的数据和代码为例进行比较:
> db.test.find()
{
"_id" : ObjectId("5303f24423d2721c25c493ee"),
"ts" : NumberLong("635186135151387725")
}
{
"_id" : ObjectId("5303f24a23d2721c25c493ef"),
"ts" : NumberLong("635186135151387726")
}
>
以及要查找的代码:
var MongoClient = require('mongodb').MongoClient;
var Long = require('mongodb').Long;
MongoClient.connect('mongodb://localhost/test', function(err, db) {
var collection = db.collection('test');
var value = Long.fromString("635186135151387726");
console.log( value );
var cursor = collection.find({ ts: {"$gte": value} });
cursor.toArray(function(err, items) {
console.log( items );
});
});
按预期提供输出:
{ _bsontype: 'Long', low_: -1342987186, high_: 147890796 }
[ { _id: 5303f24a23d2721c25c493ef,
ts: { _bsontype: 'Long', low_: -1342987186, high_: 147890796 } } ]
关于javascript - Node js Mongodb查询NumberLong,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21870044/
我在 MongoDB 数据库中存储了一些 XML 数据。一些数据存储为 Numberlong(1234),另一些数据存储为 Numberlong("12353")。示例: "nodes_id" : [
我有一个 json,它类似于 {"Header": {"name": "TestData", "contactNumber": 8019071740}} 如果我将它插入到 mongoDB 中,它将类似
我从 mondb 收到了一个 JSON 字段: "publishDate": NumberLong("1500948351000"), 我尝试用 Java 来解析它: String docTime =
我正在尝试从 mongoDB 获取特定数据。我有 5 个字段,用户可以根据这些字段进行搜索。这是我的代码: Map fields = new HashMap(); if (textField.getT
我正在尝试获取一个集合中的所有文档,其中的日期存储如下: { "_id": { "$oid": "5c500ff8df157e051961cfab" }, "date": {
我正在使用 mongo 2.4。 我有一个包含这两个条目的集合: > db.collection.find({domain: "pow.com"}) { "_id" : ObjectId("577ee
我的文档中有一个字段为 "p_id" : NumberLong(2328703838) 我尝试如下获取它 spec.find({p_id: id}) 我的 ID 是 2328703838...但是即
目前我正在使用 MongoDB 将数据收集到 PHP 表中,在我的 MongoDB 集合中有以下数据 > db.AETOM.find().pretty() { "_id" : {
我使用 mongoexport 将集合导出到 json 文件(脚本如下)。 mongoexport -d db1 -c user --out/root/user_130226.json 发现那些类型为
我的 Java 应用程序中有一个带有字段的类 Instant created; 这个在mongo中存储为 "created" : NumberLong("1467359610266") (f.e.)
mongodb 文档中的整数值保存 32int。我想在 mongodb 中保存 64 位值。 代码在这里: import time import datetime from pymongo impor
我在Mongo Shell中写了以下4条语句 i) NumberLong(3) ii) NumberLong(3)+NumberLong(4) iii) typeof NumberLong(3) iv
MongoDB 的 NumberLong 真的是 64 位有符号整数吗? 据说 MongoDB 的 NumberLong 是一个 64 位有符号整数,这意味着我们可以使用 -2^63 = 2^54 的
我正在尝试用其他一些 NumberLong 值更新我的一个集合中的一些 NumberLong 类型值。以下是我的收藏结构: { "_id" : ObjectId("55e57337d4
如何在 Mongo shell 中对 NumberLong 值执行精确运算?据我了解,Javascript 只有一种数字类型 - number - 通常限于 54 位浮点精度。 使用(例如)标准加法的
我已将 CSV 文件导入我的 mongodb。 CSV 具有 mongo 所需的分隔符,并通过以下查询从 MySQL 数据库接收: SELECT * FROM csgo_users INTO OUTF
我正在尝试使用 mongodb java 驱动程序从集合中计算平均值,如下所示: DBObject condition = new BasicDBObject("pluginIdentifie
我需要将数据插入到我的 mongoDB 中,如下所示: db.collection('Test').insert({ "Name" : "Some", "UserID" : Num
如何将 mongodb 字段数据类型从 NumberLong 更改为 Double? 我试过没有成功: db.getCollection('mycoll').find({'_id':101500971
为什么我的 mongodb-stitch 服务会返回值的类型($numberLong、$numberInt,...),而 Compass 应用程序却没有? 如何使用与 Compas 中相同的变量格式,
我是一名优秀的程序员,十分优秀!