Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-4082

Update documentation on timestamp constructor

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • v1.3.12
    • None
    • manual
    • None

    Description

      Timestamps documentation reads:

      If you create a BSON Timestamp using the empty constructor (e.g. new Timestamp()), MongoDB will only generate a timestamp if you use the constructor in the first field of the document. [2] Otherwise, MongoDB will generate an empty timestamp value (i.e. Timestamp(0, 0).)

      And then:

      [2]
      If the first field in the document is _id, then you can generate a timestamp in the second field of a document.

      In the following example, MongoDB will generate a Timestamp value, even though the Timestamp() constructor is not in the first field in the document:

      db.bios.insert( { _id: 9, last_updated: new Timestamp() } )

      But as shown in SERVER-15367 this is no longer the case. The behavior seems be be new in 2.6.

      Attachments

        Activity

          People

            andrew.aldridge@mongodb.com Andrew Aldridge
            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9 years, 18 weeks ago