Home >Database >Mysql Tutorial >mongodb中的游标使用

mongodb中的游标使用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 14:58:50976browse

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.hasNex

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);

});

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:ubuntu install mongodbNext article:postgressql批量增加数据