Learn R Programming

rmongodb (version 1.8.0)

mongo.bson.buffer.append.symbol: Append a symbol field onto a mongo.bson.buffer

Description

Append a symbol value onto a mongo.bson.buffer.

Usage

mongo.bson.buffer.append.symbol(buf, name, value)

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
(string) The value of the symbol.

Note that the value may simply be a string representing the symbol's value and not necessarily a mongo.symbol object.

Value

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

Details

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

See Also

mongo.bson, mongo.bson.buffer, mongo.symbol, mongo.symbol.create, mongo.bson.buffer.append.

Examples

Run this code
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.symbol(buf, "A", "Alpha")
b <- mongo.bson.from.buffer(buf)

# The above produces a BSON object of the form { "A" : (SYMBOL) "Alpha" }

# The same result can be produced by the following code:
buf <- mongo.bson.buffer.create()
sym <- mongo.symbol.create("Alpha")
mongo.bson.buffer.append(buf, "A", sym)
b <- mongo.bson.from.buffer(buf)

Run the code above in your browser using DataLab