in src/InMemoryProvider.ts [495:519]
public put(
itemOrItems: ItemType | ItemType[],
skipTransactionOnCreation?: boolean
): void {
if (!skipTransactionOnCreation && !this._trans!.internal_isOpen()) {
throw new Error("InMemoryTransaction already closed");
}
const items = arrayify(itemOrItems);
// If it's not the PK index, re-pivot the data to be keyed off the key value built from the keypath
each(items, (item) => {
// Each item may be non-unique so store as an array of items for each key
const keys = this.internal_getKeysFromItem(item);
each(keys, (key) => {
// For non-unique indexes we want to overwrite
if (!this.isUniqueIndex() && this._indexTree.has(key)) {
const existingItems = this._indexTree.get(key)!!! as ItemType[];
existingItems.push(item);
this._indexTree.set(key, existingItems);
} else {
this._indexTree.set(key, [item]);
}
});
});
}