mongodb中的游标使用示例如下:
假设执行如下操作:
db.XXX.remove();
db.XXX.insert({"name":"BuleRiver1", "age":27});
db.XXX.insert({"name":"BuleRiver2", "age":23});
db.XXX.insert({"name":"BuleRiver3", "age":21});
使用find()返回一个游标:
var cursor = db.XXX.find();
while (cursor.hasNext()) {
obj = cursor.next();
print(obj.name);
}
使用游标的forEach()循环遍历:
cursor.forEach(function(x) {
print(x.name);
});
最后
以上就是温婉咖啡豆最近收集整理的关于mongodb数据库游标的使用浅析的全部内容,更多相关mongodb数据库游标内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复