Learn R Programming

rmongodb (version 1.8.0)

mongo.bson.buffer.start.object: Start a subobject within a mongo.bson.buffer

Description

BSON documents may themselves contain nested documents. Call this function to start a subobject within a mongo.bson.buffer.

Usage

mongo.bson.buffer.start.object(buf, name)

Arguments

buf
(mongo.bson.buffer) The buffer object to which to append.
name
(string) The name (key) of the subobject to be appended to the buffer.

Value

TRUE if successful; otherwise, FALSE if an error occured appending the data.

Details

mongo.bson.buffer.finish.object() must be called when finsihed appending subfields. (mongo.bson.buffer.start.object(), mongo.bson.buffer.start.array()) and mongo.bson.buffer.finish.object() may be called in a stackwise (LIFO) order to further nest documents and arrays.

See Also

mongo.bson, mongo.bson.buffer, mongo.bson.buffer.finish.object, mongo.bson.buffer.start.array, mongo.bson.buffer.append.

Examples

Run this code
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.start.object(buf, "name")
mongo.bson.buffer.append(buf, "first", "Jeff")
mongo.bson.buffer.append(buf, "last", "Davis")
mongo.bson.buffer.finish.object(buf)
mongo.bson.buffer.append(buf, "city", "Toronto")
b <- mongo.bson.from.buffer(buf)

# the above produces a BSON object of the form:
# { "name" : { "first" : "Jeff", "last" : "Davis" }, "city" : "Toronto" }

Run the code above in your browser using DataLab