SQL >> Base de Datos >  >> NoSQL >> MongoDB

MongoDB en PHP: usar aggregate para agrupar por _id es null y no funciona

Usa el objeto MongoRegex:

$search = "apc"; $where = array('Store.Title' => array('$regex' => new MongoRegex("/^$search/gi"))); // $where = array('Store.Title' => array('$regex' => new MongoRegex("/".$search."/gi"))); [ [ '$match' => $where ], [ '$group' => [ '_id' => 'null', 'count' => [ '$sum' => 1 ] ] ] ]