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

camadb

v2.0.0

Published

A TypeScript embedded database

Downloads

389

Readme

CamaDB

CamaDB is a NoSQL embedded database written in pure TypeScript for Node, Electron and browser-based environments.

semantic-release

Why?

I was struggling to find a solution for Electron-based projects that deal with larger datasets in the main thread.

  • I had issues getting SQLite to work with webpack due to its native build
  • SQLite doesn't (by default) return native JS data types (Dates in particular)
  • Other NoSQL embedded databases seem to be largely abandoned
  • Most other NoSQL embedded databases seem to be limited by V8's hard string length limits

Goals

  • Fast querying/insertion/manipulation of data, up to 1 million rows
  • Frictionless integration with all JS runtimes
  • Rich API
  • Full TypeScript support
  • Simplicity and versatility - This is built for storing data in dynamic structures

Current state

This is still under active development and a few features are missing:

  • Indexes - We're finding that this is fast even without these, but every little helps
  • Rich text search

Getting started

Documentation

Installing

yarn add reflect-metadata
yarn add camadb

OR

npm install reflect-metadata --save
npm install camadb --save

Initializing the database

All of these config options are optional:

  • path - Where you want the data to be stored - default is ./.cama or cama for indexeddb and localstorage
  • persistenceAdapter - How you want to persist your data - fs, indexeddb, localstorage or inmemory
  • logLevel - info or debug
  import { Cama } from 'camadb'
  const database = new Cama({
    path: './.cama',
    persistenceAdapter: 'fs',
    logLevel: 'debug'
  });

Initializing a collection

  • Use the columns field to add specific data types for rows. This does need to be done for each column, but is essential for date objects
  • Indexes aren't currently implemented, but the lookup is still very fast across 10 million rows
 const collection = await database.initCollection('test', {
    columns: [{
      type:'date',
      title:'date'
    }],
    indexes: [],
  });

Insert one

 await collection.insertOne({
    _id: 'test',
    name: 'Dummy field',
    description: `Data`,
  });

Insert many

  await collection.insertMany([{
       _id: 'test',
       name: 'Dummy field',
       description: `Data`,
  }]);

Find many

CamaDB uses a MongoDB style query language, powered by SiftJS. Have a look at that project to see the full capabilities of that library.

 const findResult = await collection.findMany({
    _id: {
      $gte: 50000,
    },
  },
    {
      sort:{
        desc: x => x._id
      },
      offset: 100,
      limit: 100
    });

Updating

Again we use a MongoDB style language for data updates, for this we use obop

  await collection.updateMany({
    _id:3
  }, {
    $set: {
      steve:"steve"
    }
  });

Aggregation

We use Mingo for aggregation - currently lookup commands aren't supported.

 const aggregationResult = await collection.aggregate([{
    $match:{
      _id:3
    }
  }]);