Description Usage Arguments Details Value See Also Examples
View source: R/mongo_records.R
Add record to a collection.
1 | mongo.insert(mongo, ns, b)
|
mongo |
(mongo) a mongo connection object. |
ns |
(string) namespace of the collection to which to add the record. |
b |
(mongo.bson) The record to add. In addition, |
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.batch
,
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 | mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
ns <- "test.people"
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Joe")
mongo.bson.buffer.append(buf, "age", 22L)
b <- mongo.bson.from.buffer(buf)
mongo.insert(mongo, ns, b)
# do the same thing in shorthand:
mongo.insert(mongo, ns, list(name="Joe", age=22L))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.