mongo.bson.buffer.append.code.w.scope: Append a code field with a scope onto a mongo.bson.buffer

Description Usage Arguments Details Value See Also Examples

View source: R/bson.R

Description

Append a javascript code value with a scope object 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

mongo.code.w.scope The scoped javascript code.

Details

BSON has a special field type to indicate javascript code with a scope. 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.w.scope,
mongo.code.w.scope.create,
mongo.bson.buffer.append,
mongo.bson.from.list,
mongo.bson.buffer,
mongo.bson.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
scope <- mongo.bson.from.list(list(scopevar="scopevalue"))
buf <- mongo.bson.buffer.create()
codeWscope <- mongo.code.w.scope.create("y = x", scope)
mongo.bson.buffer.append.code.w.scope(buf, "CodeWscope1",
     codeWscope)

# mongo.bson.buffer.append() will give the same result
# as it can detect the mongo.code.w.scope object
mongo.bson.buffer.append(buf, "CodeWscope2", codeWscope)

b <- mongo.bson.from.buffer(buf)

# The above produces a BSON object of the form:
# { "CodeWscope1" : (CODEWSCOPE) "y = x"
#        (SCOPE) { "scopevar" : "scopevalue" },
#   "CodeWscope2" : (CODEWSCOPE) "y = x"
#        (SCOPE) { "scopevar" : "scopevalue" } }

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