npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

choxy

v2.0.1

Published

The reactive state management system and wrapper for IndexedDB

Downloads

15

Readme

Choxy

Build Status

The reactive state management system and wrapper for IndexedDB.

Choxy allows you to easily handle, save data to IndexedDB

Installation

npm i choxy

Usage

Add

import choxy from 'choxy'

choxy.add(key, value)

Get

import choxy from 'choxy'

choxy.get(key)

Update

import choxy from 'choxy'

choxy.update(key, newValue)

Remove

import choxy from 'choxy'

choxy.remove(key)

Watch

import choxy from 'choxy'

// Callback will trigger when value of key change. Method return id_watch
// With option is immediate = true then callback will trigger when init value

id = choxy.watch(key, callback, { immediate: true | false})

Unwatch

import choxy from 'choxy'

choxy.unwatch(key, id)

Wrapper for IndexedDB

Create database

db = new choxy.idb('MyDatabase')

await db.version(1).create({
  friends: '++id,name,age',        // first field is id
  customers: 'snn,name,age,&email' // With field is unique then add prefix '&' for field
})

nameDatabase: nameDatabase what you want crate

version: version of database. It necessary when you want create objectStore then version must greater current version

tables: Object store with key is name table and type of value is string format primaryKey,field1,field2,...

++id: primaryKey autoincrement start from 1

Init database

db = new choxy.idb('MyDatabase')

await db.init()

Add entry to Table

status = await db.query('customers').add({snn: '111-11-1111', name: 'john', email: '[email protected]', age: 24})

If status equal true then add success and otherwise

Remove entry to Table

status = await db.query('customers').delete('111-11-1111')

Update entry to Table

status = await db.query('customers').update('111-11-1111', {snn: '111-11-1111', name: 'john', email: '[email protected]', age: 27})

Clear all entry from Table

status = await db.query('customers').clear()

Get entry from Table

entry = await db.query('customers').get('111-11-1111')

Get all entries from Table

entries = await db.query('customers').getAll().offset(1).limit(4).sortBy((a,b) => b.age - a.age).toArray()

offset: Get entries from index offset

limit: Return limit entries

sortBy: Take callback which similar Array.sort()

toArray: Necessary return entries as array

Get Count entries from Table

count = await db.query('customers').count()

Iterate each entry from Table

db.query('customers').forEach(entry => {
  console.log('Key: ', entry.key, 'Value: ', entry.value)
})

Find range above

await db.query(table).where(field).above(x)

Find range aboveOrEqual

await db.query(table).where(field).aboveOrEqual(x)

Find range below

await db.query(table).where(field).below(y)

Find range belowOrEqual

await db.query(table).where(field).belowOrEqual(y)

Find between

await db.query(table).where(field).between(x, y, equalX, equalY)

// equalX: false, equalY: false   --> >= x and <= y
// equalX: false, equalY: true    --> >=x and < y
// equalX: true, equalY: false    --> < x and <= y
// equalX: true, equalY: true     --> < x and < y