[PHP] About $size operator in aggregate $project

113 views
Skip to first unread message

張瀚文

unread,
Aug 5, 2015, 3:06:54 AM8/5/15
to mongodb-user
Hi:
I use php aggregate method to calculate group result, when I use $size operator in $project, 
like the following code 
array(
         '$project' => array(
                    "action_sum" => array('$size'=>'$action')
        )
),
the result as following
exception: invalid operator '$size'

I don't know what happened to my code, does any one know?

thanks a lot

PHP version is 5.5.9


Rhys Campbell

unread,
Aug 5, 2015, 4:46:31 AM8/5/15
to mongodb-user
What version of MongoDB are you running? The docs state $size in new in v2.6

張瀚文

unread,
Aug 6, 2015, 3:22:25 AM8/6/15
to mongodb-user
Thank you, your reply helps me a lot, the problem was found, our version of MongoDB is v2.4, I haven't noticed this situation.

Rhys Campbell於 2015年8月5日星期三 UTC+8下午4時46分31秒寫道:
Reply all
Reply to author
Forward
0 new messages