I got these documents:
- users -> id, name, friendList (_id, name), createdOn
I have to search for a friend in the friend list so what I got is:
$users->find(array('_id' => $userId, 'friendList.name' => new MongoRegex('/' . strtolower($keyword) . '/'), array('friendList.name')));
The problem is that it will return all friendlist names, how can I just obtain the information about the “friend” I am trying to search?
Thanks for help already 🙂
You cannot do this in mongo, you can search for a particular element, but mongo will always return the whole array, so you have to extract the element yourself.