Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created April 18, 2012 02:48
Show Gist options
  • Save michaeltwofish/2410753 to your computer and use it in GitHub Desktop.
Save michaeltwofish/2410753 to your computer and use it in GitHub Desktop.
Lithium MongoDB unique tags from users
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