serialize static method
Serializes a document into a BSON binary object
Implementation
static BsonBinary serialize(var object, [int offset = 0]) {
if (!((object is Map) || (object is List))) {
throw Exception('Invalid value for BsonCodec.serialize: $object');
}
var bsonObject = BsonObject.from(object, bsonSerialization);
var buffer = BsonBinary(bsonObject.totalByteLength + offset);
buffer.offset = offset;
bsonObject.packValue(buffer);
return buffer;
}