Skip to content
This repository was archived by the owner on Jun 7, 2019. It is now read-only.

Live updating leveldb + react component for counting the k/v pairs under a prefix

Notifications You must be signed in to change notification settings

juliangruber/react-level-count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-level-count

Live updating leveldb + react component for counting the k/v pairs under a prefix!

Example

import React from 'react'
import level from 'level'
import { Count } from 'react-level-count'

const db = level('/tmp/react-level-count')

class Example extends React.Component {
  render () {
    return (
      <div>
        Live count: <Count db={db} prefix="prefix" />
      </div>
    )
  }
}

Now the <Count /> component will always reflect the number of k/v pairs you have stored in your database with the prefix prefix.

Find a full example in /example:

$ npm install
$ npm run rebuild
$ npm start

screenshot

Installation

$ npm install react-level-value

API

<Count db [prefix filter render] />

Use filter to pick what adds to the count, like so:

<Count
  db={db}
  filter={({ key, value }) => true}
/>

Use render for a custom render function:

<Count
  db={db}
  render={count => <strong>{count}</strong>}
/>

License

MIT

About

Live updating leveldb + react component for counting the k/v pairs under a prefix

Resources

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published