mongo.symbol: The mongo.symbol class

Description Details See Also Examples

Description

Objects of class "mongo.symbol" are used to represent symbol values in BSON documents.

Details

mongo.symbol objects' value is a string representing the value of the symbol.

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

These mongo.symbol 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.symbol.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
buf <- mongo.bson.buffer.create()
sym <- mongo.symbol.create("Beta")
mongo.bson.buffer.append(buf, "B", sym)
l <- list(s1 = sym, Two = 2)
mongo.bson.buffer.append.list(buf, "listWsym", l)
b <- mongo.bson.from.buffer(buf)

# the above will create a mongo.bson object of the following form:
# { "B": (SYMBOL) "Beta",
#   "listWsym" : { "s1" : (SYMBOL) "Beta",
#                  "Two" : 2 } }

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