mongodb - How to store TimeStamp? Is there automatic field for CreatedOn -


I am new to Mongo DB. I have to create code and document, but there is no timestamp field. Any way to insert documents automatically is

  db.createCollection ("country"); // created archive db.countries.insert ({"short_name": "air force", "country_name": "Afghanistan"}); // created document db.countries.find () {"_id": ObjectId ("53d1d5bcb8173a625961ff34"), "short_name": "air force", "country_name": "Afghanistan"}   

How do you do when I actually use the default "made_on" in my documents using Cx PHP?

Mongodb will not automatically insert anything except the '_id' field. You can take the time to merge with the '_id' field like this -

Object ID ("507c7f79bcf86cd7994f6c0e"). GetTimestamp ()

The result will appear if you want to include these fields. -

isadatt ( "2012-10-15T21: 26: 17Z")

  • If you are on Mongo Shell then the new date will be included () .

    db.mycollection.insert ({'created_on': new date ()})

  • And if you use raw PHP

    Hope it helps: -)

  • Comments

    Popular posts from this blog

    ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

    Matlab transpose a table vector -

    c# - Textbox not clickable but editable -