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

@cloudblob/store

v1.1.2

Published

Provider agnostic searchable document store that runs on cloud object storage

Downloads

15

Readme

cloudblob-store

Build status Coverage Status Maintainability

Node document store built on cloud persistent storage - currently only AWS S3 is supported. Hope to add Azure Blob storage and Google Cloud Storage soon.

Overview

Use cloudblob-store as a hobbyist, for prototyping or even for scaling (this would require a propper caching strategy to keep request time quick).

Offers indexing & search capabilities out the box through the help of libraries like, FlexSearch and Elasticlunr.

Why

Sometimes you need a data storage backend which is rarely updated and frequently read and should scale when required. Combining the persistence of cloud object/blob storage and serverless architecture gives us that versatility, scaleability and ease of development.

The cloudblob stack was developed to provide a lightweight datastore solution for high read and low write applications that's also very easy to implement and also extremely cost effective. Combine this with caching and indexing workers to provide a scaleable eventually consistent data store.

One of the main aims is to avoid vendor lock-in. If you want to host your own stack have a look at cloudblob-server.

The interface of the datastore client is simple enough. If the latency of cloud storage doesn't work for you, and you've already tried caching. You could always just wrap a mongo client with the same interface.

Getting started

Install the package

npm install @cloudblob/store

Example Usage

const {Datastore, AWS, Flexsearch} = require('@cloudblob/store');

var awsConfig = {
    // AWS-sdk s3 client parameters
    accessKeyId: "xxx...",
    secretAccessKey: "xxx..."
}

const store = new Datastore({
  // the db name here is the bucket name
  db: 'example-database',
  storage: new AWS(awsConfig),
  // specify the namespaces and their indexer class, each namespace can use a different indexer
  // so you can optimise for different types of data
  namespaces: {
    // the parameters for the indexer are (fields array, unique ref)
    user:  {
        indexer: new Flexsearch(['name', 'about', 'age'], '_id'), // the 'indexer' field is optional. Use it if you want namespace to be searchable.
        ref: "_id" // unique field to use for constructing storage key/path
    }
  }
});

var doc = {
    name: "John Doe",
    about: "Lorem ipsum dolar sit amet...",
    age: '30'
}

// save a document, it returns a promise that resolves the saved document (including it's autogenerated unique reference)
store.put('user', doc).then(console.log)
// Prints
// {
//     _id: "<auto_generated_uuid4_hex>",
//     name: "John Doe",
//     about: "I'm a deceased person",
//     age: '30'
// }

// index the document, the namespace index file is lazyloaded
store.index('user', doc).then(console.log)

// at this stage a manual index flush/dump is required.
store.dumpIndex('user').then(console.log)
// prints 
// 'true' or 'false'

// read the document
store.get('user', 'some_doc_key').then(console.log)

// search namespace index (returns key only by default)
store.filter('user', 'John Doe').then(console.log)

// list namespace documents as a paginated response
store.list('user').then(console.log)

Improvements

  • Move the storage backend code to separate repositories to reduce unnecessary SDK bloat
  • Move indexers to separate package
  • Implementing a shardable indexer since index files are lazy loaded