Learn R Programming

rmongodb (version 1.8.0)

mongo.code.w.scope: The mongo.code.w.scope class

Description

Objects of class "mongo.code.w.scope" are used to represent javascript code values with scopes in BSON documents.

Arguments

Details

mongo.code.w.scope objects' value is a string representing the value of the code.

The scope is a mongo.bson object and is stored in the "scope" attribute of the mongo.code.w.scope object.

mongo.code.w.scope objects have "mongo.code.w.scope" as their class so that mongo.bson.buffer.append() may detect them and append the appropriate BSON code-typed value and scope to a buffer.

These mongo.code.w.scope values may also be present in a list and will be handled properly by mongo.bson.buffer.append.list() and mongo.bson.from.list().

See Also

mongo.code.w.scope.create, 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, "sv", "sx")
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)
lst <- list(c1 = codeWscope, One = 1)
mongo.bson.buffer.append.list(buf, "listWcodeWscope", lst)
b <- mongo.bson.from.buffer(buf)

# the above will create a mongo.bson object of the following form:
# { "CodeWscope" : (CODEWSCOPE) "y = x"
#                  (SCOPE) { "sv" : "sx"},
#   "listWcodeWscope" : { "c1" : (CODEWSCOPE) "y = x"
#                                (SCOPE) { "sv" : "sx"} } }

Run the code above in your browser using DataLab