note 100880 added to mongocollection.group

From: Date: Fri, 12 Nov 2010 13:05:58 +0000
Subject: note 100880 added to mongocollection.group
Groups: php.notes 
Request: Send a blank email to php-notes+get-173977@lists.php.net to get a copy of this message
Here I am posting how I get tags from my documents. Documents should have 'tags' field which is array of strings: {'tags':['php', 'mongo']} <?php $keys = array(); $initial = array('tags'=>array(), 'count'=>0); $reduce = 'function (doc, total) { if (doc.tags.length) {doc.tags.forEach(function (e) {total.tags[e]=total.tags[e]||0; total.tags[e]++; total.count++;});} }'; $criteria = array( 'condition' => array( 'tags' => array('$exists'=>true) ), ); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 83.234.124.166 ---- Manual Page -- http://www.php.net/manual/en/mongocollection.group.php Edit -- https://master.php.net/note/edit/100880 Del: integrated -- https://master.php.net/note/delete/100880/integrated Del: useless -- https://master.php.net/note/delete/100880/useless Del: bad code -- https://master.php.net/note/delete/100880/bad+code Del: spam -- https://master.php.net/note/delete/100880/spam Del: non-english -- https://master.php.net/note/delete/100880/non-english Del: in docs -- https://master.php.net/note/delete/100880/in+docs Del: other reasons-- https://master.php.net/note/delete/100880 Reject -- https://master.php.net/note/reject/100880 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173977) next »