mongo.bson.iterator.key: Return the key (name) of the field pointed to by an iterator

Description Usage Arguments Value See Also Examples

View source: R/bson.R

Description

Return the key (name) of the field pointed to by a mongo.bson.iterator.

Usage

1

Arguments

iter

A mongo.bson.iterator.

Value

(string) The key (name) of the field pointed to by iter

See Also

mongo.bson.iterator,
mongo.bson.iterator.create,
mongo.bson.find,
mongo.bson.iterator.next,
mongo.bson.iterator.type,
mongo.bson.iterator.value,
mongo.bson.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
buf <- mongo.bson.buffer.create()
# Append a string
mongo.bson.buffer.append(buf, "name", "Joe")
# Append a date/time
mongo.bson.buffer.append(buf, "created", Sys.time())
# Append a NULL
mongo.bson.buffer.append(buf, "cars", NULL)
b <- mongo.bson.from.buffer(buf)

# iterate through all values and print them with their keys (names)
iter <- mongo.bson.iterator.create(b)
while (mongo.bson.iterator.next(iter)) { # eoo at end stops loop
    print(mongo.bson.iterator.key(iter))
    print(mongo.bson.iterator.value(iter))
}

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