Learn R Programming

rmongodb (version 1.8.0)

mongo.bson.buffer.finish.object: Finish a subobject or array within a mongo.bson.buffer

Description

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

Usage

mongo.bson.buffer.finish.object(buf)

Arguments

buf
(mongo.bson.buffer) The buffer object on which to finish a subobject.

Value

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

Details

mongo.bson.buffer.start.object() and mongo.bson.buffer.finish.object() may be called in a stackwise (LIFO) order to further nest documents.

This function must also be called to finish arrays.

See Also

mongo.bson, mongo.bson.buffer, mongo.bson.buffer.start.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