0

let's assume I do this:

$person = array(
   "_id" => new MongoId(),
   "name" => "Fabs",
   "city" => "Rome"
);

$people->save($person);

Can I be sure of the fact _id will be unique when $person is actually persisted? Because, after all, the id has been created "outside" of the DB (without the DB knowing) and there might well be that very id in the people collection already, no? I also understand it might be very unlikely but is it possible at all?

nourdine
  • 7,407
  • 10
  • 46
  • 58

1 Answers1

1

Of course it's possible, as it is with any other ID generation scheme that doesn't involve a central registry of IDs. The chance of it happening is so low, though, that i can safely assert that you'll never see it happen unless malice is involved.

cHao
  • 84,970
  • 20
  • 145
  • 172