idb: extend test case
This commit is contained in:
parent
b3fc710d9a
commit
df5619236b
@ -214,6 +214,23 @@ test("Spec: Example 1 Part 3", async t => {
|
|||||||
cursor = request6.result;
|
cursor = request6.result;
|
||||||
t.is(cursor, null);
|
t.is(cursor, null);
|
||||||
|
|
||||||
|
|
||||||
|
const request7 = index5.openCursor(null, "prevunique");
|
||||||
|
await promiseFromRequest(request7);
|
||||||
|
cursor = request7.result;
|
||||||
|
t.is(cursor.value.author, "Fred");
|
||||||
|
t.is(cursor.value.isbn, 234567);
|
||||||
|
cursor.continue();
|
||||||
|
|
||||||
|
await promiseFromRequest(request7);
|
||||||
|
cursor = request7.result;
|
||||||
|
t.is(cursor.value.author, "Barney");
|
||||||
|
cursor.continue();
|
||||||
|
|
||||||
|
await promiseFromRequest(request7);
|
||||||
|
cursor = request7.result;
|
||||||
|
t.is(cursor, null);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
t.pass();
|
t.pass();
|
||||||
|
@ -640,7 +640,16 @@ export class MemoryBackend implements Backend {
|
|||||||
objectStoreProperties.indexes.push(indexName);
|
objectStoreProperties.indexes.push(indexName);
|
||||||
schema.indexes[indexName] = indexProperties;
|
schema.indexes[indexName] = indexProperties;
|
||||||
|
|
||||||
// FIXME: build index from existing object store!
|
const objectStore = myConn.objectStoreMap[objectStoreName];
|
||||||
|
if (!objectStore) {
|
||||||
|
throw Error("object store does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
const storeData = objectStore.modifiedData || objectStore.originalData;
|
||||||
|
|
||||||
|
storeData.forEach((v, k) => {
|
||||||
|
this.insertIntoIndex(newIndex, k, v.value, indexProperties);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteRecord(
|
async deleteRecord(
|
||||||
|
@ -53,7 +53,7 @@ export interface IMapSource<K=any, V=any> extends ISetSource<K>
|
|||||||
/** Calls callbackFn once for each key-value pair present in the map object.
|
/** Calls callbackFn once for each key-value pair present in the map object.
|
||||||
* The ES6 Map class sends the value to the callback before the key, so
|
* The ES6 Map class sends the value to the callback before the key, so
|
||||||
* this interface must do likewise. */
|
* this interface must do likewise. */
|
||||||
forEach(callbackFn: (v:V, k:K, map:IMapSource<K,V>) => void, thisArg: any): void;
|
forEach(callbackFn: (v:V, k:K, map:IMapSource<K,V>) => void, thisArg?: any): void;
|
||||||
|
|
||||||
/** Returns an iterator that provides all key-value pairs from the collection (as arrays of length 2). */
|
/** Returns an iterator that provides all key-value pairs from the collection (as arrays of length 2). */
|
||||||
entries(): IterableIterator<[K,V]>;
|
entries(): IterableIterator<[K,V]>;
|
||||||
|
Loading…
Reference in New Issue
Block a user