mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-27 08:22:31 +00:00
refactor: Do not return hash as part of iterator result.
This commit is contained in:
parent
61fe23c8d5
commit
3f70f4ddd2
@ -19,7 +19,7 @@ const Events = async ({ OpLog, Database, ipfs, identity, databaseId, accessContr
|
|||||||
const iterator = async function * ({ gt, gte, lt, lte, amount } = {}) {
|
const iterator = async function * ({ gt, gte, lt, lte, amount } = {}) {
|
||||||
const it = log.iterator({ gt, gte, lt, lte, amount })
|
const it = log.iterator({ gt, gte, lt, lte, amount })
|
||||||
for await (const event of it) {
|
for await (const event of it) {
|
||||||
yield { hash: event.hash, value: event.payload.value }
|
yield event.payload.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ const KeyValue = async ({ OpLog, Database, ipfs, identity, databaseId, accessCon
|
|||||||
const { op, key, value } = entry.payload
|
const { op, key, value } = entry.payload
|
||||||
if (op === 'PUT' && !keys[key]) {
|
if (op === 'PUT' && !keys[key]) {
|
||||||
keys[key] = true
|
keys[key] = true
|
||||||
yield { hash: entry.hash, value: { key, value } }
|
yield { key, value }
|
||||||
} else if (op === 'DEL' && !keys[key]) {
|
} else if (op === 'DEL' && !keys[key]) {
|
||||||
keys[key] = true
|
keys[key] = true
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
const all = await db.all()
|
const all = await db.all()
|
||||||
|
|
||||||
deepStrictEqual(all.map(e => e.value), events)
|
deepStrictEqual(all, events)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Iterator Options', () => {
|
describe('Iterator Options', () => {
|
||||||
@ -128,7 +128,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 1)
|
strictEqual(all.length, 1)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns two items', async () => {
|
it('returns two items', async () => {
|
||||||
@ -140,7 +140,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 2)
|
strictEqual(all.length, 2)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns three items', async () => {
|
it('returns three items', async () => {
|
||||||
@ -152,7 +152,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 3)
|
strictEqual(all.length, 3)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets \'amount\' greater than items available', async () => {
|
it('sets \'amount\' greater than items available', async () => {
|
||||||
@ -164,7 +164,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 5)
|
strictEqual(all.length, 5)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets \'amount\' to 0', async () => {
|
it('sets \'amount\' to 0', async () => {
|
||||||
@ -176,7 +176,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 0)
|
strictEqual(all.length, 0)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 4)
|
strictEqual(all.length, 4)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns one item less than head', async () => {
|
it('returns one item less than head', async () => {
|
||||||
@ -202,7 +202,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 1)
|
strictEqual(all.length, 1)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns two items less than head', async () => {
|
it('returns two items less than head', async () => {
|
||||||
@ -214,7 +214,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 2)
|
strictEqual(all.length, 2)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 5)
|
strictEqual(all.length, 5)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns one item less than or equal to head', async () => {
|
it('returns one item less than or equal to head', async () => {
|
||||||
@ -240,7 +240,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 1)
|
strictEqual(all.length, 1)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns two items less than or equal to head', async () => {
|
it('returns two items less than or equal to head', async () => {
|
||||||
@ -252,7 +252,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 2)
|
strictEqual(all.length, 2)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 4)
|
strictEqual(all.length, 4)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns one item greater than root', async () => {
|
it('returns one item greater than root', async () => {
|
||||||
@ -278,7 +278,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 1)
|
strictEqual(all.length, 1)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns two items greater than root', async () => {
|
it('returns two items greater than root', async () => {
|
||||||
@ -290,7 +290,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 2)
|
strictEqual(all.length, 2)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 5)
|
strictEqual(all.length, 5)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns one item greater than or equal to root', async () => {
|
it('returns one item greater than or equal to root', async () => {
|
||||||
@ -316,7 +316,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 1)
|
strictEqual(all.length, 1)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns two items greater than or equal to root', async () => {
|
it('returns two items greater than or equal to root', async () => {
|
||||||
@ -328,7 +328,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 2)
|
strictEqual(all.length, 2)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strictEqual(all.length, 3)
|
strictEqual(all.length, 3)
|
||||||
deepStrictEqual(all.map(e => e.value), expected)
|
deepStrictEqual(all, expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -182,7 +182,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
all.unshift(pair)
|
all.unshift(pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
deepStrictEqual(all.map(e => e.value), keyvalue)
|
deepStrictEqual(all, keyvalue)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user