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

mongodb中的游标使用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:58:50
Original
975 people have browsed it

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

});

 

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
mongodb start
From 1970-01-01 08:00:00
0
0
0
linux - ubuntu14 error installing mongodb
From 1970-01-01 08:00:00
0
0
0
Use of symfony2 mongodb
From 1970-01-01 08:00:00
0
0
0
mongodb _id rename
From 1970-01-01 08:00:00
0
0
0
Parameter understanding of mongodb
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template