mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
buf <- mongo.bson.buffer.create()
# special Null timestamp -- automatically filled in
# if one of first two fields in a record
ts <- mongo.timestamp.create(0,0)
mongo.bson.buffer.append(buf, "InsertTime", ts)
mongo.bson.buffer.append(buf, "name", "Joe")
b <- mongo.bson.from.buffer(buf)
mongo.insert(mongo, "test.people", b)
# create using a POSIXlt
ts <- mongo.timestamp.create(strptime("05-12-2012",
"%m-%d-%Y"), increment=1)
}
Run the code above in your browser using DataLab