mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
commit
85df8784c4
3
GUIDE.md
3
GUIDE.md
@ -15,8 +15,11 @@ This guide is still being worked on and we would love to get [feedback and sugge
|
|||||||
* [Address](#address)
|
* [Address](#address)
|
||||||
+ [Manifest](#manifest)
|
+ [Manifest](#manifest)
|
||||||
* [Identity](#identity)
|
* [Identity](#identity)
|
||||||
|
+ [Creating an identity](#creating-an-identity)
|
||||||
* [Access Control](#access-control)
|
* [Access Control](#access-control)
|
||||||
+ [Public databases](#public-databases)
|
+ [Public databases](#public-databases)
|
||||||
|
+ [Granting access after database creation](#granting-access-after-database-creation)
|
||||||
|
+ [Custom Access Controller](#custom-access-controller)
|
||||||
- [Add an entry](#add-an-entry)
|
- [Add an entry](#add-an-entry)
|
||||||
- [Get an entry](#get-an-entry)
|
- [Get an entry](#get-an-entry)
|
||||||
- [Persistency](#persistency)
|
- [Persistency](#persistency)
|
||||||
|
50
package-lock.json
generated
50
package-lock.json
generated
@ -6541,9 +6541,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ipfs-log": {
|
"ipfs-log": {
|
||||||
"version": "4.3.0-rc.3",
|
"version": "github:orbitdb/ipfs-log#0c7b756a7ba3d38f75adc32dc98bd5c08e991b5e",
|
||||||
"resolved": "https://registry.npmjs.org/ipfs-log/-/ipfs-log-4.3.0-rc.3.tgz",
|
"from": "github:orbitdb/ipfs-log#cid-to-hash",
|
||||||
"integrity": "sha512-hxJMN9d6dktY7JVASB6WeKKco65UStqKVcYLPGuPAArYkgJdA2xHP3tCwF+nCbMOty+HUZ3bEdias5UHK2ov5g==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"cids": "^0.5.7",
|
"cids": "^0.5.7",
|
||||||
"ipld-dag-pb": "^0.15.2",
|
"ipld-dag-pb": "^0.15.2",
|
||||||
@ -6551,7 +6550,8 @@
|
|||||||
"orbit-db-identity-provider": "^0.1.0-rc.1.3",
|
"orbit-db-identity-provider": "^0.1.0-rc.1.3",
|
||||||
"orbit-db-io": "~0.0.1",
|
"orbit-db-io": "~0.0.1",
|
||||||
"p-map": "^1.1.1",
|
"p-map": "^1.1.1",
|
||||||
"p-whilst": "^1.0.0"
|
"p-whilst": "^1.0.0",
|
||||||
|
"pify": "^4.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ipfs-mfs": {
|
"ipfs-mfs": {
|
||||||
@ -10377,20 +10377,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-counterstore": {
|
"orbit-db-counterstore": {
|
||||||
"version": "1.5.0-rc3",
|
"version": "github:orbitdb/orbit-db-counterstore#dd26aef2bd5c95c8099ad61cc3ba4cd916d3c827",
|
||||||
"resolved": "https://registry.npmjs.org/orbit-db-counterstore/-/orbit-db-counterstore-1.5.0-rc3.tgz",
|
"from": "github:orbitdb/orbit-db-counterstore#cid-to-hash",
|
||||||
"integrity": "sha512-yqjphHuDslH26kjlRgu9JT4CFmHZOc4UBTqsduL/+6ygNs2WG4LtAhGqlCJeGHP345O2UoddPwBZUdFuJI0m6Q==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"crdts": "~0.1.2",
|
"crdts": "~0.1.2",
|
||||||
"orbit-db-store": "^2.6.0-rc3"
|
"orbit-db-store": "github:orbitdb/orbit-db-store#34e95b2166057baa165639d4f2ae52d8cd86f92f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-docstore": {
|
"orbit-db-docstore": {
|
||||||
"version": "1.5.1-rc3",
|
"version": "github:orbitdb/orbit-db-docstore#eeece9d6e2884e20c193ecd388b789871950d736",
|
||||||
"resolved": "https://registry.npmjs.org/orbit-db-docstore/-/orbit-db-docstore-1.5.1-rc3.tgz",
|
"from": "github:orbitdb/orbit-db-docstore#cid-to-hash",
|
||||||
"integrity": "sha512-Pn8uuRh7cAN/mo+5dEK71sj8EHajqeDZUjDTx1vy08s9JIhOfqqPN20aI/g67wGY1qnT7FNOdCqhxyDmtUmb6A==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"orbit-db-store": "^2.6.0-rc3",
|
"orbit-db-store": "github:orbitdb/orbit-db-store#34e95b2166057baa165639d4f2ae52d8cd86f92f",
|
||||||
"p-map": "~1.1.1"
|
"p-map": "~1.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -10402,19 +10400,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-eventstore": {
|
"orbit-db-eventstore": {
|
||||||
"version": "1.5.0-rc3",
|
"version": "github:orbitdb/orbit-db-eventstore#a01c14aebcd47c3cb3da740063f5a8ef10cd9293",
|
||||||
"resolved": "https://registry.npmjs.org/orbit-db-eventstore/-/orbit-db-eventstore-1.5.0-rc3.tgz",
|
"from": "github:orbitdb/orbit-db-eventstore#cid-to-hash",
|
||||||
"integrity": "sha512-sqCSrQby7RsviWmOv8N3Vh/dA0juHmB+XhACWvmr5tOdIbizHVBhihp10j1N7XDyWMMFI1k+3cvjk3w5Wgj5GQ==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"orbit-db-store": "^2.6.0-rc3"
|
"orbit-db-store": "github:orbitdb/orbit-db-store#34e95b2166057baa165639d4f2ae52d8cd86f92f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-feedstore": {
|
"orbit-db-feedstore": {
|
||||||
"version": "1.5.0-rc3",
|
"version": "github:orbitdb/orbit-db-feedstore#a61998066c65a9d723e4fcacab86c9e51c496911",
|
||||||
"resolved": "https://registry.npmjs.org/orbit-db-feedstore/-/orbit-db-feedstore-1.5.0-rc3.tgz",
|
"from": "github:orbitdb/orbit-db-feedstore#cid-to-hash",
|
||||||
"integrity": "sha512-OKqy6/BVC8a97G8sGgoosYHXxGQrqjY7M/cDYIG67LwT1YWOcKu3Ul3e2dmi7q9KPXpnrssgsFTqe5XPUcQqug==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"orbit-db-eventstore": "^1.5.0-rc3"
|
"orbit-db-eventstore": "github:orbitdb/orbit-db-eventstore#a01c14aebcd47c3cb3da740063f5a8ef10cd9293"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-identity-provider": {
|
"orbit-db-identity-provider": {
|
||||||
@ -10469,11 +10465,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-kvstore": {
|
"orbit-db-kvstore": {
|
||||||
"version": "1.5.0-rc4",
|
"version": "github:orbitdb/orbit-db-kvstore#52563286b9648e019e296ea848552605c4d07628",
|
||||||
"resolved": "https://registry.npmjs.org/orbit-db-kvstore/-/orbit-db-kvstore-1.5.0-rc4.tgz",
|
"from": "github:orbitdb/orbit-db-kvstore#cid-to-hash",
|
||||||
"integrity": "sha512-i84nspoR2PP5J7so+W/2uJmujYQtflP5VDW/4dPdzEF2HmKHR4i7wPeww+yekFon9845kTyfGxOarTQ3lEVw4Q==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"orbit-db-store": "^2.6.0-rc3"
|
"orbit-db-store": "github:orbitdb/orbit-db-store#34e95b2166057baa165639d4f2ae52d8cd86f92f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-pubsub": {
|
"orbit-db-pubsub": {
|
||||||
@ -10487,11 +10482,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orbit-db-store": {
|
"orbit-db-store": {
|
||||||
"version": "2.6.0-rc3",
|
"version": "github:orbitdb/orbit-db-store#34e95b2166057baa165639d4f2ae52d8cd86f92f",
|
||||||
"resolved": "https://registry.npmjs.org/orbit-db-store/-/orbit-db-store-2.6.0-rc3.tgz",
|
"from": "github:orbitdb/orbit-db-store#cid-to-hash",
|
||||||
"integrity": "sha512-a967cwLLjR+JIDbA2vUwDQ6i7+LSRydx7zy69zsQsAGK+A7vQylpqtUkN/N14Zz++RKbbrqG2a5CWzBWA90Ejg==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ipfs-log": "^4.3.0-rc.3",
|
"ipfs-log": "github:orbitdb/ipfs-log#0c7b756a7ba3d38f75adc32dc98bd5c08e991b5e",
|
||||||
"logplease": "^1.2.14",
|
"logplease": "^1.2.14",
|
||||||
"orbit-db-io": "~0.0.1",
|
"orbit-db-io": "~0.0.1",
|
||||||
"p-each-series": "^1.0.0",
|
"p-each-series": "^1.0.0",
|
||||||
|
12
package.json
12
package.json
@ -20,16 +20,16 @@
|
|||||||
"multihashes": "^0.4.12",
|
"multihashes": "^0.4.12",
|
||||||
"orbit-db-access-controllers": "next",
|
"orbit-db-access-controllers": "next",
|
||||||
"orbit-db-cache": "~0.2.4",
|
"orbit-db-cache": "~0.2.4",
|
||||||
"orbit-db-counterstore": "next",
|
"orbit-db-counterstore": "github:orbitdb/orbit-db-counterstore#cid-to-hash",
|
||||||
"orbit-db-docstore": "next",
|
"orbit-db-docstore": "github:orbitdb/orbit-db-docstore#cid-to-hash",
|
||||||
"orbit-db-eventstore": "next",
|
"orbit-db-eventstore": "github:orbitdb/orbit-db-eventstore#cid-to-hash",
|
||||||
"orbit-db-feedstore": "next",
|
"orbit-db-feedstore": "github:orbitdb/orbit-db-feedstore#cid-to-hash",
|
||||||
"orbit-db-identity-provider": "rc1.3",
|
"orbit-db-identity-provider": "rc1.3",
|
||||||
"orbit-db-io": "~0.0.1",
|
"orbit-db-io": "~0.0.1",
|
||||||
"orbit-db-keystore": "rc1.2",
|
"orbit-db-keystore": "rc1.2",
|
||||||
"orbit-db-kvstore": "next",
|
"orbit-db-kvstore": "github:orbitdb/orbit-db-kvstore#cid-to-hash",
|
||||||
"orbit-db-pubsub": "~0.5.5",
|
"orbit-db-pubsub": "~0.5.5",
|
||||||
"orbit-db-store": "next"
|
"orbit-db-store": "github:orbitdb/orbit-db-store#cid-to-hash"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^6.26.0",
|
"babel-core": "^6.26.0",
|
||||||
|
@ -62,20 +62,20 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const hash = await db.add('hello1')
|
const hash = await db.add('hello1')
|
||||||
const items = db.iterator({ limit: -1 }).collect()
|
const items = db.iterator({ limit: -1 }).collect()
|
||||||
assert.notEqual(hash, null)
|
assert.notEqual(hash, null)
|
||||||
assert.equal(hash, last(items).cid)
|
assert.equal(hash, last(items).hash)
|
||||||
assert.equal(items.length, 1)
|
assert.equal(items.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the added entry\'s hash, 2 entries', async () => {
|
it('returns the added entry\'s hash, 2 entries', async () => {
|
||||||
db = await orbitdb1.feed(address)
|
db = await orbitdb1.feed(address)
|
||||||
await db.load()
|
await db.load()
|
||||||
const prevHash = db.iterator().collect()[0].cid
|
const prevHash = db.iterator().collect()[0].hash
|
||||||
const hash = await db.add('hello2')
|
const hash = await db.add('hello2')
|
||||||
const items = db.iterator({ limit: -1 }).collect()
|
const items = db.iterator({ limit: -1 }).collect()
|
||||||
assert.equal(items.length, 2)
|
assert.equal(items.length, 2)
|
||||||
assert.notEqual(hash, null)
|
assert.notEqual(hash, null)
|
||||||
assert.notEqual(hash, prevHash)
|
assert.notEqual(hash, prevHash)
|
||||||
assert.equal(hash, last(items).cid)
|
assert.equal(hash, last(items).hash)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds five items', async () => {
|
it('adds five items', async () => {
|
||||||
@ -130,7 +130,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
|
|
||||||
const firstItem = items[0]
|
const firstItem = items[0]
|
||||||
const secondItem = items[1]
|
const secondItem = items[1]
|
||||||
assert.equal(firstItem.cid.startsWith('zd'), true)
|
assert.equal(firstItem.hash.startsWith('zd'), true)
|
||||||
assert.equal(firstItem.payload.key, null)
|
assert.equal(firstItem.payload.key, null)
|
||||||
assert.equal(firstItem.payload.value, 'hello2')
|
assert.equal(firstItem.payload.value, 'hello2')
|
||||||
assert.equal(secondItem.payload.value, 'hello3')
|
assert.equal(secondItem.payload.value, 'hello3')
|
||||||
@ -159,7 +159,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const iter = db.iterator()
|
const iter = db.iterator()
|
||||||
const next = iter.next().value
|
const next = iter.next().value
|
||||||
assert.notEqual(next, null)
|
assert.notEqual(next, null)
|
||||||
assert.equal(next.cid.startsWith('zd'), true)
|
assert.equal(next.hash.startsWith('zd'), true)
|
||||||
assert.equal(next.payload.key, null)
|
assert.equal(next.payload.key, null)
|
||||||
assert.equal(next.payload.value, 'hello4')
|
assert.equal(next.payload.value, 'hello4')
|
||||||
})
|
})
|
||||||
@ -178,7 +178,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const iter = db.iterator()
|
const iter = db.iterator()
|
||||||
const first = iter.next().value
|
const first = iter.next().value
|
||||||
const second = iter.next().value
|
const second = iter.next().value
|
||||||
assert.equal(first.cid, hashes[hashes.length - 1])
|
assert.equal(first.hash, hashes[hashes.length - 1])
|
||||||
assert.equal(second, null)
|
assert.equal(second, null)
|
||||||
assert.equal(first.payload.value, 'hello4')
|
assert.equal(first.payload.value, 'hello4')
|
||||||
})
|
})
|
||||||
@ -218,7 +218,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const iter = db.iterator({ limit: 0 })
|
const iter = db.iterator({ limit: 0 })
|
||||||
const first = iter.next().value
|
const first = iter.next().value
|
||||||
const second = iter.next().value
|
const second = iter.next().value
|
||||||
assert.equal(first.cid, last(hashes))
|
assert.equal(first.hash, last(hashes))
|
||||||
assert.equal(second, null)
|
assert.equal(second, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const iter = db.iterator({ limit: 1 })
|
const iter = db.iterator({ limit: 1 })
|
||||||
const first = iter.next().value
|
const first = iter.next().value
|
||||||
const second = iter.next().value
|
const second = iter.next().value
|
||||||
assert.equal(first.cid, last(hashes))
|
assert.equal(first.hash, last(hashes))
|
||||||
assert.equal(second, null)
|
assert.equal(second, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -236,16 +236,16 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const second = iter.next().value
|
const second = iter.next().value
|
||||||
const third = iter.next().value
|
const third = iter.next().value
|
||||||
const fourth = iter.next().value
|
const fourth = iter.next().value
|
||||||
assert.equal(first.cid, hashes[hashes.length - 3])
|
assert.equal(first.hash, hashes[hashes.length - 3])
|
||||||
assert.equal(second.cid, hashes[hashes.length - 2])
|
assert.equal(second.hash, hashes[hashes.length - 2])
|
||||||
assert.equal(third.cid, hashes[hashes.length - 1])
|
assert.equal(third.hash, hashes[hashes.length - 1])
|
||||||
assert.equal(fourth, null)
|
assert.equal(fourth, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns all items', () => {
|
it('returns all items', () => {
|
||||||
const messages = db.iterator({ limit: -1 })
|
const messages = db.iterator({ limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
messages.reverse()
|
messages.reverse()
|
||||||
assert.equal(messages.length, hashes.length)
|
assert.equal(messages.length, hashes.length)
|
||||||
@ -255,7 +255,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns all items when limit is bigger than -1', () => {
|
it('returns all items when limit is bigger than -1', () => {
|
||||||
const messages = db.iterator({ limit: -300 })
|
const messages = db.iterator({ limit: -300 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, hashes.length)
|
assert.equal(messages.length, hashes.length)
|
||||||
assert.equal(messages[0], hashes[0])
|
assert.equal(messages[0], hashes[0])
|
||||||
@ -264,7 +264,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns all items when limit is bigger than number of items', () => {
|
it('returns all items when limit is bigger than number of items', () => {
|
||||||
const messages = db.iterator({ limit: 300 })
|
const messages = db.iterator({ limit: 300 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, hashes.length)
|
assert.equal(messages.length, hashes.length)
|
||||||
assert.equal(messages[0], hashes[0])
|
assert.equal(messages[0], hashes[0])
|
||||||
@ -276,7 +276,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns 1 item when gte is the head', () => {
|
it('returns 1 item when gte is the head', () => {
|
||||||
const messages = db.iterator({ gte: last(hashes), limit: -1 })
|
const messages = db.iterator({ gte: last(hashes), limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, 1)
|
assert.equal(messages.length, 1)
|
||||||
assert.equal(messages[0], last(hashes))
|
assert.equal(messages[0], last(hashes))
|
||||||
@ -291,7 +291,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const gte = hashes[hashes.length - 2]
|
const gte = hashes[hashes.length - 2]
|
||||||
const messages = db.iterator({ gte: gte, limit: -1 })
|
const messages = db.iterator({ gte: gte, limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, 2)
|
assert.equal(messages.length, 2)
|
||||||
assert.equal(messages[0], hashes[hashes.length - 2])
|
assert.equal(messages[0], hashes[hashes.length - 2])
|
||||||
@ -301,7 +301,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns all items when gte is the root item', () => {
|
it('returns all items when gte is the root item', () => {
|
||||||
const messages = db.iterator({ gte: hashes[0], limit: -1 })
|
const messages = db.iterator({ gte: hashes[0], limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, hashes.length)
|
assert.equal(messages.length, hashes.length)
|
||||||
assert.equal(messages[0], hashes[0])
|
assert.equal(messages[0], hashes[0])
|
||||||
@ -311,7 +311,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns items when gt is the root item', () => {
|
it('returns items when gt is the root item', () => {
|
||||||
const messages = db.iterator({ gt: hashes[0], limit: -1 })
|
const messages = db.iterator({ gt: hashes[0], limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, itemCount - 1)
|
assert.equal(messages.length, itemCount - 1)
|
||||||
assert.equal(messages[0], hashes[1])
|
assert.equal(messages[0], hashes[1])
|
||||||
@ -321,13 +321,13 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns items when gt is defined', () => {
|
it('returns items when gt is defined', () => {
|
||||||
const messages = db.iterator({ limit: -1})
|
const messages = db.iterator({ limit: -1})
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
const gt = messages[2]
|
const gt = messages[2]
|
||||||
|
|
||||||
const messages2 = db.iterator({ gt: gt, limit: 100 })
|
const messages2 = db.iterator({ gt: gt, limit: 100 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages2.length, 2)
|
assert.equal(messages2.length, 2)
|
||||||
assert.equal(messages2[0], messages[messages.length - 2])
|
assert.equal(messages2[0], messages[messages.length - 2])
|
||||||
@ -339,7 +339,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns one item after head when lt is the head', () => {
|
it('returns one item after head when lt is the head', () => {
|
||||||
const messages = db.iterator({ lt: last(hashes) })
|
const messages = db.iterator({ lt: last(hashes) })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, 1)
|
assert.equal(messages.length, 1)
|
||||||
assert.equal(messages[0], hashes[hashes.length - 2])
|
assert.equal(messages[0], hashes[hashes.length - 2])
|
||||||
@ -348,7 +348,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns all items when lt is head and limit is -1', () => {
|
it('returns all items when lt is head and limit is -1', () => {
|
||||||
const messages = db.iterator({ lt: last(hashes), limit: -1 })
|
const messages = db.iterator({ lt: last(hashes), limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, hashes.length - 1)
|
assert.equal(messages.length, hashes.length - 1)
|
||||||
assert.equal(messages[0], hashes[0])
|
assert.equal(messages[0], hashes[0])
|
||||||
@ -358,7 +358,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns 3 items when lt is head and limit is 3', () => {
|
it('returns 3 items when lt is head and limit is 3', () => {
|
||||||
const messages = db.iterator({ lt: last(hashes), limit: 3 })
|
const messages = db.iterator({ lt: last(hashes), limit: 3 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, 3)
|
assert.equal(messages.length, 3)
|
||||||
assert.equal(messages[0], hashes[hashes.length - 4])
|
assert.equal(messages[0], hashes[hashes.length - 4])
|
||||||
@ -373,7 +373,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns one item when lte is the root item', () => {
|
it('returns one item when lte is the root item', () => {
|
||||||
const messages = db.iterator({ lte: hashes[0] })
|
const messages = db.iterator({ lte: hashes[0] })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, 1)
|
assert.equal(messages.length, 1)
|
||||||
assert.equal(messages[0], hashes[0])
|
assert.equal(messages[0], hashes[0])
|
||||||
@ -382,7 +382,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns all items when lte is the head', () => {
|
it('returns all items when lte is the head', () => {
|
||||||
const messages = db.iterator({ lte: last(hashes), limit: -1 })
|
const messages = db.iterator({ lte: last(hashes), limit: -1 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, itemCount)
|
assert.equal(messages.length, itemCount)
|
||||||
assert.equal(messages[0], hashes[0])
|
assert.equal(messages[0], hashes[0])
|
||||||
@ -392,7 +392,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('returns 3 items when lte is the head', () => {
|
it('returns 3 items when lte is the head', () => {
|
||||||
const messages = db.iterator({ lte: last(hashes), limit: 3 })
|
const messages = db.iterator({ lte: last(hashes), limit: 3 })
|
||||||
.collect()
|
.collect()
|
||||||
.map((e) => e.cid)
|
.map((e) => e.hash)
|
||||||
|
|
||||||
assert.equal(messages.length, 3)
|
assert.equal(messages.length, 3)
|
||||||
assert.equal(messages[0], hashes[hashes.length - 3])
|
assert.equal(messages[0], hashes[hashes.length - 3])
|
||||||
|
@ -98,7 +98,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
const hash = await db.add({ thing: 'new addition'})
|
const hash = await db.add({ thing: 'new addition'})
|
||||||
const newEntries = db.all.filter(e => e.v === 1)
|
const newEntries = db.all.filter(e => e.v === 1)
|
||||||
assert.equal(newEntries.length, 1)
|
assert.equal(newEntries.length, 1)
|
||||||
assert.strictEqual(newEntries[0].cid, hash)
|
assert.strictEqual(newEntries[0].hash, hash)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user