Hi, I'm using mongodb to store some data and is working fine, but I don't know how to remove documents, I'm doing:

$collection = mongodb_collection("mycollection");
$collection->remove(array('_id' => $id));

Where $id would be the mongodb id, something like "4f937d5f74b25e8d4f000000".

But this is not working. Can someone please point me in the right direction?

Thanks in advance

Comments

lelizondo’s picture

I found that something like this will work:

$collection->remove(array('_id' => new MongoId($id)), true);

MiSc’s picture

Status: Active » Closed (works as designed)

This is not related to the Mongodb module, so I am closing this one.

lelizondo’s picture

Status: Closed (works as designed) » Fixed

Yes it was related to the Mongo db module because I'm using the module and I needed help.

Anyway, I already solve it and I forgot to mark it as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.