Learn R Programming

rmongodb (version 1.8.0)

mongo.timestamp.create: Create a mongo.timestamp object

Description

Create a mongo.timestamp object for appending to a buffer with mongo.bson.buffer.append.timestamp() or mongo.bson.buffer.append(), or for embedding in a list such that mongo.bson.buffer.append.list() will properly insert a timestamp value into the mongo.bson.buffer object.

Usage

mongo.timestamp.create(time, increment)

Arguments

time
(integer) date/time value (milliseconds since UTC epoch).

This may also be a "POSIXct" or "POSIXlt" class object.

increment
increment ordinal

Value

A mongo.timestamp object

Details

See http://www.mongodb.org/display/DOCS/Timestamp+Data+Type

See Also

mongo.timestamp, mongo.bson.buffer.append, mongo.bson.buffer.append.time, mongo.bson.buffer.append.list, mongo.bson.buffer, mongo.bson.

Examples

Run this code
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