@fireproof/core 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/fireproof.d.ts +2 -2
- package/dist/src/fireproof.js +195 -223
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +195 -223
- package/dist/src/fireproof.mjs.map +1 -1
- package/package.json +1 -1
- package/src/db-index.js +13 -7
- package/src/listener.js +2 -2
package/package.json
CHANGED
package/src/db-index.js
CHANGED
@@ -244,7 +244,8 @@ export class DbIndex {
|
|
244
244
|
let removeByIdIndexEntries = []
|
245
245
|
await loadIndex(blocks, this.indexById, idIndexOpts)
|
246
246
|
await loadIndex(blocks, this.indexByKey, dbIndexOpts)
|
247
|
-
|
247
|
+
// console.log('head', this.dbHead, this.indexById)
|
248
|
+
if (this.indexById.root) {
|
248
249
|
const oldChangeEntries = await this.indexById.root.getMany(result.rows.map(({ key }) => key))
|
249
250
|
oldIndexEntries = oldChangeEntries.result.map((key) => ({ key, del: true }))
|
250
251
|
removeByIdIndexEntries = oldIndexEntries.map(({ key }) => ({ key: key[1], del: true }))
|
@@ -292,13 +293,18 @@ async function bulkIndex (blocks, inIndex, indexEntries, opts) {
|
|
292
293
|
inIndex.root = await load({ cid, get: getBlock, ...dbIndexOpts })
|
293
294
|
}
|
294
295
|
const { root, blocks: newBlocks } = await inIndex.root.bulk(indexEntries)
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
await
|
296
|
+
if (root) {
|
297
|
+
returnRootBlock = await root.block
|
298
|
+
returnNode = root
|
299
|
+
for await (const block of newBlocks) {
|
300
|
+
await putBlock(block.cid, block.bytes)
|
301
|
+
}
|
302
|
+
await putBlock(returnRootBlock.cid, returnRootBlock.bytes)
|
303
|
+
return { root: returnNode, cid: returnRootBlock.cid }
|
304
|
+
} else {
|
305
|
+
// throw new Error('test for index after delete')
|
306
|
+
return { root: null, cid: null }
|
299
307
|
}
|
300
|
-
await putBlock(returnRootBlock.cid, returnRootBlock.bytes)
|
301
|
-
return { root: returnNode, cid: returnRootBlock.cid }
|
302
308
|
}
|
303
309
|
|
304
310
|
async function loadIndex (blocks, index, indexOpts) {
|
package/src/listener.js
CHANGED
@@ -41,9 +41,9 @@ export class Listener {
|
|
41
41
|
* @returns {Function} A function to unsubscribe from the topic.
|
42
42
|
* @memberof Listener
|
43
43
|
* @instance
|
44
|
-
* @param {any} since
|
44
|
+
* @param {any} [since] - clock to flush from on launch
|
45
45
|
*/
|
46
|
-
on (topic, subscriber, since) {
|
46
|
+
on (topic, subscriber, since = undefined) {
|
47
47
|
const listOfTopicSubscribers = getTopicList(this.subcribers, topic)
|
48
48
|
listOfTopicSubscribers.push(subscriber)
|
49
49
|
if (typeof since !== 'undefined') {
|