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

Description Details See Also Examples

Description

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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"} } }

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