mongo.bson.buffer.start.array: Start an array within a mongo.bson.buffer

Description Usage Arguments Details Value See Also Examples

View source: R/bson.R

Description

Call this function to start an array within a mongo.bson.buffer.
mongo.bson.buffer.finish.object() must be called when finished appending the elements of the array.

Usage

1

Arguments

buf

(mongo.bson.buffer) The buffer object to which to append.

name

(string) The name (key) of the array to be appended to the buffer.

Details

(mongo.bson.buffer.start.object(), mongo.bson.buffer.start.array()) and
mongo.bson.buffer.finsih.object() may be called in a stackwise (LIFO) order to further nest arrays and documents.

The names of the elements appended should properly be given sequentially numbered strings.

Note that arrays will be automatically appended by the 'append' functions when appending vectors (containing more than one element) of atomic types.

Value

TRUE if successful; otherwise, FALSE if an error occured appending the data.

See Also

mongo.bson,
mongo.bson.buffer,
mongo.bson.buffer.finish.object,
mongo.bson.buffer.start.array,
mongo.bson.buffer.append.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.start.array(buf, "Fibonacci")
x <- 0
mongo.bson.buffer.append.int(buf, "0", x)
y <- 1
mongo.bson.buffer.append.int(buf, "1", y)
for (i in 2:8) {
    z <- x + y
    mongo.bson.buffer.append.int(buf, as.character(i), z)
    x <- y
    y <- z
}
mongo.bson.buffer.finish.object(buf)
b <- mongo.bson.from.buffer(buf)

# the above produces a BSON object of the form:
# { "Fibonacci" : [ 0, 1, 1, 2, 3, 5, 8, 13, 21 ] }

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