Description Usage Arguments Details Value Note See Also Examples
Convert a list to a mongo.bson object.
1 | mongo.bson.from.list(lst)
|
lst |
(list) The list to convert. This must be a list, not a vector of atomic types; otherwise,
an error is thrown; use |
This function permits the simple and convenient creation of a mongo.bson
object. This bypasses the creation of a mongo.bson.buffer, appending
fields one by one, and then turning the buffer into a mongo.bson object with
mongo.bson.from.buffer()
.
Note that this function and mongo.bson.to.list()
perform inverse conversions.
(mongo.bson) A mongo.bson object serialized from lst
.
Function converts unnamed R lists into bson arrays. It is very easy to construct bson object of any form using this function and list.
mongo.bson.to.list
,
mongo.bson,
mongo.bson.destroy
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | lst <- list(name="John", age=32)
b <- mongo.bson.from.list(lst)
# the above produces a BSON object of the form:
# { "name" : "John", "age" : 32.0 }
# Convert a vector of an atomic type to a list and
# then to a mongo.bson object
v <- c(president="Jefferson", vice="Burr")
b <- mongo.bson.from.list(as.list(v))
# the above produces a BSON object of the form:
# { "president" : "Jefferson", "vice" : "Burr" }
# Let's try to construct bson with array.
# This one
mongo.bson.from.list(list(fruits = list('apple', 'banana', 'orange')))
# will produce a BSON object of the form:
# {"fruits" : ["apple", "banana", "orange"]}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.