Learn R Programming

rmongodb (version 1.8.0)

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

Description

Append a javascript code value onto a mongo.bson.buffer.

Usage

mongo.bson.buffer.append.code(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

Value

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

Details

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

See Also

mongo.code, mongo.code.create, mongo.bson.buffer.append, mongo.bson, mongo.bson.buffer.

Examples

Run this code
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.code(buf, "SetXtoY", "x = y")
b <- mongo.bson.from.buffer(buf)

# The above produces a BSON object of the form:
# { "SetXtoY" : (CODE) "x = y" }

# The same result can be produced by the following code:
buf <- mongo.bson.buffer.create()
code <- mongo.code.create("x = y")
mongo.bson.buffer.append(buf, "SetXtoY", code)
b <- mongo.bson.from.buffer(buf)

Run the code above in your browser using DataLab