Learn R Programming

rmongodb (version 1.8.0)

mongo.bson.buffer.append.raw: Append a raw (binary) field onto a mongo.bson.buffer

Description

Append raw (binary) data onto a mongo.bson.buffer.

Usage

mongo.bson.buffer.append.raw(buf, name, value, subtype = NULL)

Arguments

buf
(mongo.bson.buffer) The buffer object to which to append.
name
(string) The name (key) of the field appended to the buffer.
value
(raw) the binary data.
subtype
(as.integer) The binary data subtype. If subtype == NULL, the "subtype" attribute of the raw is used. If this is not present, mongo.binary.binary is used. The following constants are defined:

Value

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

Details

BSON has a special field type to indicate binary data. This function appends such an indicator as the type of a field with its value.

If value has a dims attribute of length > 1, any names or dimnames attribute is ignored and a nested array is appended. (Use mongo.bson.buffer.append.object() if you want to preserve dimnames).

See Also

mongo.bson.buffer.append, mongo.bson, mongo.bson.buffer.

Examples

Run this code
buf <- mongo.bson.buffer.create()
bin <- raw(3)
for (i in 0:2)
    bin[i] <- as.raw(i * 3)
mongo.bson.buffer.append.raw(buf, "bin1", bin)

# Note that mongo.bson.buffer.append()
# will detect whether the value parameter
# is a raw object and append the appropriate value.

mongo.bson.buffer.append(buf, "bin2", bin)  # gives same result

Run the code above in your browser using DataLab