'Update one record of a list of records
with new keys and values and update indices'

def update(self, records, **kw):

    kw = dict([(k, v) for (k, v) in kw.items() if (k in self.fields)])
    if isinstance(records, dict):
        records = [records]
    for indx in (set(self.indices.keys()) & set(kw.keys())):
        for record in records:
            if (record[indx] == kw[indx]):
                continue
            _id = record['__id__']
            old_pos = (bisect.bisect(self.indices[indx][record[indx]], _id) - 1)
            del self.indices[indx][record[indx]][old_pos]
            if (not self.indices[indx][record[indx]]):
                del self.indices[indx][record[indx]]
            bisect.insort(self.indices[indx].setdefault(kw[indx], []), _id)
    for record in records:
        record.update(kw)
        record['__version__'] += 1
