mongo.bson.buffer.append: Append a name/value pair into a mongo.bson.buffer

Description Usage Arguments Details Value See Also Examples

View source: R/bson.R

Description

Append a name/value pair into a mongo.bson.buffer.

Usage

1

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

The value of the field.

Details

This function is a generic version of many 'append' functions. It will detect the type of the value parameter and perform the same action as the specific functions. These functions are:

mongo.bson.buffer.append.long() is missing from the above list since R has no 64-bit long integer type. If you wish a value to be stored in the BSON data as a long you must explicity call that function.

All of the above functions will lose the attributes of the object other than "names". When vectors of length > 1 are appended, "names" are preserved.
mongo.bson.buffer.append.object() gets around this shortcoming and allows most R objects to be stored in a database without loss of attributes.

Value

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

See Also

mongo.bson,
mongo.bson.buffer.

Examples

1
2
3
4
5
6
7
8
buf <- mongo.bson.buffer.create()
# Append a string
mongo.bson.buffer.append(buf, "name", "Joe")
# Append a date/time
mongo.bson.buffer.append(buf, "created", Sys.time())
# Append a NULL
mongo.bson.buffer.append(buf, "cars", NULL)
b <- mongo.bson.from.buffer(buf)

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