Created
April 18, 2012 02:48
-
-
Save michaeltwofish/2410753 to your computer and use it in GitHub Desktop.
Lithium MongoDB unique tags from users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get | |
array | |
'assertion' => string 'reduce -> multiple not supported yet' (length=36) | |
'assertionCode' => int 10075 | |
'errmsg' => string 'db assertion failure' (length=20) | |
'ok' => float 0 | |
From | |
public static function uniqueTags($client_id) { | |
$self = static::_object(); | |
$source = $self->_meta['source']; | |
$map = "function() { | |
if (!this.tags) { | |
return; | |
} | |
this.tags.forEach(function(tag) { | |
emit(tag,tag); | |
}) | |
}"; | |
$reduce = "function (key, values) { | |
return values; | |
}"; | |
// Run the command | |
$tags = $self::connection()->connection->command(array( | |
'mapreduce' => $source, | |
'map' => $map, | |
'reduce' => $reduce, | |
'out' => array('inline' => 1) | |
)); | |
var_dump($tags); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment