mongo.bson.find: Find a field within a mongo.bson object by name

Description Usage Arguments Details Value See Also Examples

View source: R/bson.R

Description

Find a field within a mongo.bson object by the name (key) of the field
and return a mongo.bson.iterator pointing to that field.

Usage

1

Arguments

b

(mongo.bson) The object in which to find the field.

name

(string) The name of the field to find.

Details

The search parameter may also be a 'dotted' reference to a field in a subobject or array. See examples.

Value

(mongo.bson.iterator) An iterator pointing to the field found if name was found among the names of the fields; otherwise, NULL.

See Also

mongo.bson.iterator,
mongo.bson.iterator.value,
mongo.bson.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
b <- mongo.bson.from.list(list(name="John", age=32L,
     address=list(street="Vine", city="Denver", state="CO")))
iter <- mongo.bson.find(b, "age")
print(mongo.bson.iterator.value(iter)) # print 32

iter <- mongo.bson.find(b, "address.city")
print(mongo.bson.iterator.value(iter)) # print Denver

x <- c(1,1,2,3,5)
b <- mongo.bson.from.list(list(fib=x))
iter <- mongo.bson.find(b, "fib.3")  # BSON arrays are 0-based
print(mongo.bson.iterator.value(iter)) # print 3

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