Description Usage Arguments Value See Also Examples
Return the value of the field pointed to by a mongo.bson.iterator.
1 |
iter |
A mongo.bson.iterator. |
The value of the field pointed to by iter
.
This function returns an appropriate R object depending on the type of the field pointed to by the iterator. This mapping to values is as follows:
mongo.bson.eoo | 0L |
mongo.bson.double | A double |
mongo.bson.string | A string |
mongo.bson.object | (See below). |
mongo.bson.array | (See below). |
mongo.bson.binary | A raw vector. (See below). |
mongo.bson.undefined | A mongo.undefined object |
mongo.bson.oid | A mongo.oid object |
mongo.bson.bool | A logical |
mongo.bson.date | A "POSIXct" class object |
mongo.bson.null | NULL |
mongo.bson.regex
| A mongo.regex object |
mongo.bson.dbref | Error! (deprecated -- see link) |
mongo.bson.code | A mongo.code object |
mongo.bson.symbol | A mongo.symbol object |
mongo.bson.code.w.scope | A mongo.code.w.scope object |
mongo.bson.int | An integer |
mongo.bson.timestamp | A mongo.timestamp object |
mongo.bson.long | A double |
Special handling:
mongo.bson.object
: If the object is recognized as a complex
value (of the form "r" : double, "i" : double ), a complex value is
returned. If the special wrapper as output by
mongo.bson.buffer.append.object()
is detected, an
appropriately attributed R object is returned; otherwise, a list is returned
containing the subfields.
mongo.bson.array
: If all fields of the array are of the same
atomic type, a vector of that type is returned. (Multidimensinal arrays are
detected and the dims
attribute will be set accordingly. Arrays of
complex values are also detected as above). Otherwise, a list is returned
containing the subfields.
mongo.bson.binary
: If non-zero, the subtype of the binary data
is stored in the attribute "subtype". See
mongo.bson.buffer.append.raw()
.
mongo.bson.iterator,
mongo.bson.iterator.create
,
mongo.bson.find
,
mongo.bson.iterator.next
,
mongo.bson.iterator.key
,
mongo.bson.iterator.type
,
mongo.bson.
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))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.