Learn R Programming

rmongodb (version 1.8.0)

mongo.code.w.scope.create: Create a mongo.code.w.scope object

Description

Create a mongo.code.w.scope object for appending to a buffer with mongo.bson.buffer.append() or for embedding in a list such that mongo.bson.buffer.append.list() will properly insert a code value into the mongo.bson.buffer object.

Usage

mongo.code.w.scope.create(code, scope)

Arguments

code
(string) javascript code
scope
(mongo.bson) the scope object

Value

A mongo.code.w.scope object

See Also

mongo.code.w.scope, mongo.bson.buffer.append, mongo.bson.buffer.append.list, mongo.bson.buffer, mongo.bson.

Examples

Run this code
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "scopevar", "scopevalue")
scope <- mongo.bson.from.buffer(buf)
codeWscope <- mongo.code.w.scope.create("y = x", scope)
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "CodeWscope", codeWscope)
b <- mongo.bson.from.buffer(buf)

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

Run the code above in your browser using DataLab