mongo.cursor.to.list: Convert Mongo Cursor Object to List so that each element of...

Description Usage Arguments Details Value See Also Examples

Description

Converts a mongo cursor object to a list by interating over all cursor objects and combining them. It doesn't make any data coercion!, just one-to-one mapping with documents in source collection.

Usage

1
mongo.cursor.to.list(cursor, keep.ordering = TRUE)

Arguments

cursor

(mongo.cursor) A mongo.cursor object returned from mongo.find().

keep.ordering

should the records be returned at the same order as fetched from cursor (if sorting was specified in query)? For speed try to set this parameter to FALSE. This will prevent sorting after fetching from cursor.

Details

Since rmongodb 1.8.0 function uses environments to avoid extra copying, so now it is much faster.

Value

An R list object.

See Also

mongo.find

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    buf <- mongo.bson.buffer.create()
    mongo.bson.buffer.append(buf, "age", 22L)
    query <- mongo.bson.from.buffer(buf)

    # Find the first 100 records
    #    in collection people of database test where age == 22
    cursor <- mongo.find(mongo, "test.people", query, limit=100L)

    res <- mongo.cursor.to.list(cursor)

}

jonkatz2/rmongodb documentation built on May 19, 2019, 7:30 p.m.