Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lowstorage

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lowstorage

Zero-dependency, simple pseudo-database on Cloudflare R2, inspired by lowdb.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-85%
Maintainers
1
Weekly downloads
 
Created
Source

lowstorage

Zero-dependency, simple pseudo-database on Cloudflare R2, strongly inspired by lowdb 🤗(https://github.com/typicode/lowdb/).

Sponsors

Become a sponsor and have your company logo here 👉 GitHub Sponsors

Usage

lowstorage is a pure ESM package. If you're having trouble using it in your project, please read this.

import lowstorage from 'lowstorage';
// Initialize object and get users collection
const usersCol = await lowstorage(env, 'MY_TESTING_BUCKET').collection('users');

// Add new user
// you can provide _id or it will be generated as crypto.randomUUID();  -> https://developers.cloudflare.com/workers/runtime-apis/web-crypto/
const newUser = await usersCol.insert({
	name: 'Kevin',
	gender: 'whatever',
	posts: [],
});

// Show all users
const allUsers = usersCol.find({});

// Find user by ID and update name
await usersCol.update({ _id: id }, { name: 'Carlos' });

Features

  • Lightweight
  • Minimalist
  • Familiar API
  • plain JavaScript
  • Zero-dependency

Install

npm install lowstorage
Why Cloudflare R2?

Seamless migration, robust free tier, Nonee gress fees. Dive into the future of data storage with Cloudflare R2 https://developers.cloudflare.com/r2/

But after all, it seems quite slow ...

API

  • insert (object {} or array [] of objects) - return array - check #Limitations

  • find(query object eg. {_id: id}) - return array of objects

  • findOne - same as find, but return only array of one object, equivalent to the db.collection.find(query)

  • update - (query{} , update {}) - return promise of updated objects

  • updateOne - same as update, but very limited

  • delete (query {}) delete specific file or all inside collection

  • remove () - removing all files inside collection

  • count () - is equivalent to the db.collection.find(query).count() construct

Examples

Check out dummy examples

Limitations

  • no test coverage, use carefully
  • response speed (no benchmarks so far)
  • inserting 1000+ entries results in hitting request limit
	Error: Too many API requests by single worker invocation.

Keywords

FAQs

Package last updated on 24 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc