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

Description Usage Arguments Details Value See Also Examples

View source: R/bson.R

Description

Append a javascript code value onto 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

string

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.

Value

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

See Also

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

Examples

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

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