orbitdb-archive / orbit-db-feedstore

Log database for orbit-db
MIT License
16 stars 6 forks source link

Number of elements in a feed #14

Closed cristiano-belloni closed 5 years ago

cristiano-belloni commented 6 years ago

Is there a way to get the number of elements in a feed? I'm trying to do pagination on a possibly long feed, and getting all of them doesn't seem the best way to do it.

haadcode commented 6 years ago

Not directly, but you could an ugly hack (or perhaps PR a proper solution? :)) with:

Object.keys(feed._index._index).length

It'd be good to expose count property from the feed though (basically returning the value from the above code), so that one could do:

const itemsCount = feed.count
aphelionz commented 5 years ago

@cristiano-belloni A later update has created a db.index getter function to simplify this. Closing for now.