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

@dwkerwin/s3db

v2.0.2

Published

S3DB provides a database like interface for the Amazon S3 object storage service. The motivation behind S3DB is cost effectiveness. By leveraging S3 as a datastore, you can significantly reduce costs compared to using a database like Amazon DynamoDB. Howe

Downloads

338

Readme

S3DB

S3DB provides a database like interface for the Amazon S3 object storage service. The motivation behind S3DB is cost effectiveness. By leveraging S3 as a datastore, you can significantly reduce costs compared to using a database like Amazon DynamoDB. However, it's important to note that S3DB is not a drop in replacement for a database. Underneath the interface, it's still S3, and it comes with the limitations inherent to an object storage service. This means that while S3DB provides a database like interface for storing and retrieving data, it should still be treated as S3. If your application can work within these limitations, S3DB offers a cost effective way to manage your data with an interface that is similar to a database, but at a fraction of the cost.

Installation

Via npm:

npm install --save @dwkerwin/s3db

Usage

AWS credentials are acquired from environment variables.

const S3DB = require('@dwkerwin/s3db');

// Create a new instance of S3DB
const s3db = new S3DB('myuserdatabucket', 'users');

// Put an item
const newUserData = { name: 'John Doe', email: '[email protected]' };
const userId = 'U12345';
await s3db.put(userId, newUserData);
// this will store newUserData at s3://myuserdatabucket/users/U12345.json
// note that the following statement is equivalent:
// await s3db.put('U12345.json', newUserData);

// Get an item
const userData = await s3db.get(userId);
// this will retrieve an object stored at s3://myuserdatabucket/users/U12345.json
console.log(`User name: ${userData.name} (${user.email})`);

// By default, `get` throws an exception if the object isn't found
// However, you can use the `returnNullIfNotFound` option to return null instead
const missingRecord = await s3db.get('thiswillnotexist', { returnNullIfNotFound: true });
if (missingRecord === null) {
    console.log('Object does not exist');
}

// Replace an item
const updatedUserData = { name: 'Jane Doe', email: '[email protected]' };
await s3db.put(userId, updatedUserData);
// this will update the object at s3://myuserdatabucket/users/U12345.json with updatedUserData

// Update an item with an additional propery, preserving existing properties
await s3db.update(userId, { address: '123 Main St.' });

// List items
const allUserKeys = await s3db.list();
// this will return a list of all items in s3://myuserdatabucket/users/,
// including items in subdirectories, e.g.: ['U12345']
for (const userKey of allUserKeys) {
    const user = s3db.get(userKey);
    console.log(`Found user: ${user.name} (${user.email})`);
}

// Delete an item
await s3db.delete(userId);
// this will delete the file at s3://myuserdatabucket/users/U12345.json
// note that the following statement is equivalent:
// s3db.delete('U12345.json');

Create Testing Infrastructure

This is to create the testin S3 bucket necessary to run unit tests. Requires the AWS CLI and active AWS credentials to be configured in the environment.

aws cloudformation create-stack --stack-name S3DBUnitTestStack --template-body file://cloudformation.yml

Test

npm test

Publish to NPM

# depends on ~/.npmrc

# update version number in package.json and then ...
npm publish --access public