mongo.timestamp objects have "mongo.timestamp", "POSIXct" & "POSIXt" as
their class so that mongo.bson.buffer.append()
may detect them
and append the appropriate BSON code-typed value to a buffer.
These mongo.timestamp values may also be present in a list and will be
handled properly by mongo.bson.buffer.append.list()
and
mongo.bson.from.list()
.
mongo.timestamp.create
,
mongo.bson.buffer.append
,
mongo.bson.buffer.append.list
, mongo.bson.buffer,
mongo.bson.
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