Learn R Programming

rmongodb (version 1.8.0)

mongo.bson.size: Get the size of a mongo.bson object

Description

Get the number of bytes taken up by the BSON data attached to the mongo.bson object

Usage

mongo.bson.size(b)

Arguments

b
(mongo.bson) the mongo.bson object to examine.

Value

(integer) the number of bytes taken up by the BSON data attached to the mongo.bson object.

See Also

mongo.bson

Examples

Run this code
# should report 5
print(mongo.bson.size(mongo.bson.empty()))

buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Fred")
mongo.bson.buffer.append(buf, "city", "Dayton")
y <- mongo.bson.from.buffer(buf)
# should report 37
print(mongo.bson.size(y))

Run the code above in your browser using DataLab