MongoDb + PHP: Cannot specify more than one positional proj. per query

Viewed 135

I have a "users" collection containing 2 arrays of objects (cards and prizes) each of these 2 can contain data from different companies marked with the "id_company" field.

$list = $users->find(
    array(
        'cards.id_company' => '... id company ...',
        'cards.is_active' => true,
    ),
    array(
        'projection' => array(
            '_id' => 1,
            'full_name' => 1,
            'cards.$.id_company' => '...id company...',
            'prizes.$.id_company' => '...id company...',
        ),
        'limit' => 5,
    )
);

I'm trying to select only the data relating to one company, consequently excluding the others, but I get the following error: Cannot specify more than one positional proj. per query. Any solutions?

0 Answers
Related