@fireproof/core 0.5.3 → 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 +194 -223
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +194 -223
- package/dist/src/fireproof.mjs.map +1 -1
- package/package.json +1 -1
- package/src/db-index.js +12 -7
- package/src/listener.js +2 -2
package/package.json
CHANGED
package/src/db-index.js
CHANGED
@@ -244,7 +244,7 @@ export class DbIndex {
|
|
244
244
|
let removeByIdIndexEntries = []
|
245
245
|
await loadIndex(blocks, this.indexById, idIndexOpts)
|
246
246
|
await loadIndex(blocks, this.indexByKey, dbIndexOpts)
|
247
|
-
console.log('head', this.dbHead, this.indexById)
|
247
|
+
// console.log('head', this.dbHead, this.indexById)
|
248
248
|
if (this.indexById.root) {
|
249
249
|
const oldChangeEntries = await this.indexById.root.getMany(result.rows.map(({ key }) => key))
|
250
250
|
oldIndexEntries = oldChangeEntries.result.map((key) => ({ key, del: true }))
|
@@ -293,13 +293,18 @@ async function bulkIndex (blocks, inIndex, indexEntries, opts) {
|
|
293
293
|
inIndex.root = await load({ cid, get: getBlock, ...dbIndexOpts })
|
294
294
|
}
|
295
295
|
const { root, blocks: newBlocks } = await inIndex.root.bulk(indexEntries)
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
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 }
|
300
307
|
}
|
301
|
-
await putBlock(returnRootBlock.cid, returnRootBlock.bytes)
|
302
|
-
return { root: returnNode, cid: returnRootBlock.cid }
|
303
308
|
}
|
304
309
|
|
305
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') {
|