【发布时间】:2011-10-30 20:23:53
【问题描述】:
我正在开发一个 REST API,我需要能够通过 MongoDB 进行分页,据我所知,cursor 是最好的方法。我可以获取光标,但是如何将其序列化以将其发送给客户端?当它回来时,服务器将如何反序列化它,并用它查询?这甚至可能吗?
collection.find({}, function(err, cursor) {
if (err) { console.log("Error in find: " + err); return;}
cursor.each(function(err, item) {
if (err) { throw err;
}
if (!item) {
console.log("All done");
} else {
console.log(sys.inspect(item));
}
});
});
问候,
【问题讨论】: