Created
November 6, 2011 10:35
-
-
Save ArtS/1342739 to your computer and use it in GitHub Desktop.
Specifying 64-bit integers for $gt queries seems broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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