0

I have activities that I should add to mongodb, activities have, dates and times, I should sort them, What I want, is not to have another field for timestamp and index that field also, I don't want the time when the document is created, I want to embed that activitie's timestamp to mongoid, I searched and tried this one but did not work,

"_id" => new MongoId($stamp)

Is there a chance, that I can embed future timestamp to mongoid ? thank you :)

Sammaye
  • 43,242
  • 7
  • 104
  • 146
user1794257
  • 115
  • 8
  • Yes this is possible but it depends on what driver you are using, i.e. the PHP driver doesn't actually allow this without making your own function. What driver are you using? – Sammaye Feb 06 '13 at 10:44
  • I am using php driver, how can I write a function for my purpose ? which functions should I add ? – user1794257 Feb 06 '13 at 10:45
  • 1
    Here is an example of doing it: http://stackoverflow.com/questions/14370143/create-mongodb-objectid-from-date-in-the-past-using-php-driver/14380093#14380093 – Sammaye Feb 06 '13 at 10:49
  • I guess I searched for wrong query :) I will try this function thank you :) – user1794257 Feb 06 '13 at 10:58

1 Answers1

1

It is possible, but not directly through the driver. I have written an example at Create MongoDB ObjectID from date in the past using PHP driver that shows you how to do this.

Community
  • 1
  • 1
Derick
  • 35,169
  • 5
  • 76
  • 99