Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
created loadByObjectId() and bugfixes in ComposeMany #20
Since i spent...quite a few hours figuring out why i could not find something in the database by its ID, i found out that there was a class given to you by the mongo php driver called MongoID which is what you wrap the hex string in to find a document by its id. I then created loadByObjectId() so you can just pass in the hex string and you don't have to remember to put your hex string into a MongoId object. But the old loadById() should be kept since keys can be anything apparently
and ComposeMany kept throwing warnings that count() was being called on a non object, so i just replaced $value->count() with count($value), and it seems to be working fine
Hey Mark - Thanks for the updates. I have already made some significant changes to a few of the classes here so automatic merging was not possible.
I am also not entirely sold on the loadByObjectId() type functions. I had other complaints/confusions when I didn't default to using MongoId() object and so I switched to using MongoId() if not id is manually defined. But I cannot assume that all ids are MongoId instances hence loadById doesn't assume that it is.
Adding these additional functions seems to be a bit redundant, it can already be done with the regular loadById. So adding it really only adds additional functions which confuses the interface a little.
I have added them for now but it might be better dealt with by adding to the documentation.