php - How to use $elemMatch on an embedded array using jenssegers/laravel-mongodb? -
my document:
{ "_id" : objectid("5824a9472e94e0995d3b0f0c"), "full_name" : "kelly denise benavides", "aliases" : [ "kelly d benavides", "kelly benavides" ] }
i wanting search document , return document if user enters 'kelly d benavides'. have tried using:
$person = person::where('aliases', 'kelly d benavides')->first();
i believe correct way using elemmatch not clear on syntax. pointers?
method #01
db.collection.find( { aliases: { $elemmatch: { "kelly d benavides" } } } )
method #02
db.collection.find({"aliases":{$elemmatch:{"$in":["kelly d benavides"], "$exists":true}}}) person::where('aliases', 'elemmatch', array('kelly d benavides'))->first(); person::where('aliases', 'all', ['kelly d benavides'])->first();
Comments
Post a Comment