Skip to content

Instantly share code, notes, and snippets.

@ArtS
Created November 6, 2011 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtS/1342739 to your computer and use it in GitHub Desktop.
Save ArtS/1342739 to your computer and use it in GitHub Desktop.
Specifying 64-bit integers for $gt queries seems broken
#!/usr/bin/env node
var mongo = require('mongodb')
db = new mongo.Db(
'test',
new mongo.Server(
'127.0.0.1',
27017,
{}
),
{}
)
function init() {
db.open(function(err, db) {
if(err) {
console.log(err)
return
}
db.collection('tweets', findTopTen)
})
}
function findTopTen(err, col) {
col.find(
{
for_user: '20937471'
},
{limit: 10, sort: [['id', 'desc']]},
function(err, cursor) {
cursor.toArray(
function(err, arr) {
findGreaterThan(col, arr)
}
)
}
)
}
function findGreaterThan(col, arr) {
console.log('Two topmost IDs: ')
console.log(arr[0].id.toString())
console.log(arr[1].id.toString())
// This should return only the first element in arr,
// theoretically
col.find(
{
for_user: '20937471',
id: {$gt: arr[1].id}
},
{limit: 10, sort: [['id', 'desc']]},
function(err, cursor) {
cursor.toArray(
function(err, arr) {
// Although it return nothing
console.log(arr)
}
)
}
)
}
init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment