fowl icon indicating copy to clipboard operation
fowl copied to clipboard

Only a single index is possible per document

Open koresar opened this issue 10 years ago • 0 comments

This is the code which adds indexes:

exports.addIndex = function(keyPath, fields)
{
  fields = _.isArray(fields) ? fields : [fields];
  var tr = transaction();
  for(var i=0; i<fields.length; i++){
    indexes.makeIndex(tr, keyPath, fields[i]);
    indexMeta[keyPath.join('/')] = true;
  }
  return tr.commit();
}

function makeIndex(tr, keyPath, value){
  return tr.put([PREFIX, '__meta'].concat(keyPath), value);
}

As you can see you create ALL indexes on the same path. So following code:

fowl.addIndex('indexedpeople', ['name', 'DOB']);

creates index __ind -> __meta -> indexedpeople is name but then overwrites it with __ind -> __meta -> indexedpeople is DOB.

koresar avatar May 23 '14 01:05 koresar