SQL >> Base de Datos >  >> NoSQL >> MongoDB

Separar y contar datos CSV en MongoDB con columnas null

El mensaje “reduce -> multiple not supported yet” aparece porque MapReduce no puede devolver un arreglo de valores.

reduce = function(key, values) { return values; }

Para devolver un único valor:

reduce = function(key, values) { return values[0]; }

También protege el mapa contra valores null:

map = function() {
  if (this.characters != null){
    var array = this.characters.split(',');
    emit(this.characters, array.length);
  }
}