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

Description Usage Arguments Details Value See Also Examples

View source: R/bson.R

Description

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

Usage

1
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:

  • mongo.binary.binary (0L)

  • mongo.binary.function (1L)

  • mongo.binary.old (2L)

  • mongo.binary.uuid (3L)

  • mongo.binary.md5 (5L)

  • mongo.binary.user (128L)

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).

Value

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

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

jonkatz2/rmongodb documentation built on May 19, 2019, 7:30 p.m.