Description Usage Arguments Details Value See Also Examples
View source: R/mongo_records.R
Add multiple records to a collection. This function eliminates some network traffic and server overhead by sending all the records in a single message.
1 | mongo.insert.batch(mongo, ns, lst)
|
mongo |
(mongo) a mongo connection object. |
ns |
(string) namespace of the collection to which to add the record. |
lst |
A list of (mongo.bson) records to add. |
See http://www.mongodb.org/display/DOCS/Inserting.
TRUE if the command was successfully sent to the server; otherwise, FALSE.
mongo.get.last.err()
may be examined to verify that the insert
was successful on the server if necessary.
mongo.insert
,
mongo.update
,
mongo.find
,
mongo.find.one
,
mongo.remove
,
mongo.bson,
mongo.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
ns <- "test.people"
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Dave")
mongo.bson.buffer.append(buf, "age", 27L)
x <- mongo.bson.from.buffer(buf)
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Fred")
mongo.bson.buffer.append(buf, "age", 31L)
y <- mongo.bson.from.buffer(buf)
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Silvia")
mongo.bson.buffer.append(buf, "city", 24L)
z <- mongo.bson.from.buffer(buf)
mongo.insert.batch(mongo, ns, list(x, y, z))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.