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

@hisorange/s3odm

v1.3.0

Published

Lightweight S3 Object Data Model

Downloads

22

Readme

S3 Object Data Mappper

S3 ODM Banner

Version Build Coverage Status NPM GitHub Last Commit GitHub License

Just a super light weight "client", currently only implements a handful of interactions. It's main goal to provide a non bloated way to interact with S3 buckets.

Getting Started

yarn add @hisorange/s3odm
# Or
npm i @hisorange/s3odm

Example Usage

import { S3ODM, Document } from '@hisorange/s3odm';

const ACCESS_KEY = 'XXXXX';
const SECRET_KEY = 'XXXXY';
const DOMAIN = '994b72fa8e67bc4167137357a2dd8763.r2.cloudflarestorage.com';
const BUCKET = 'my-database';

type User = {
  name: string;
  email: string;
  lastSeenAt: number;
} & Document;

const odm = new S3ODM(ACCESS_KEY, SECRET_KEY, DOMAIN, BUCKET);

(async () => {
  // Create a repository which maps the documents to a prefix within the bucket
  const repository = odm.createRepository<User>('users');

  // Create new document from POJOs
  const doc = await repository.insert({
    name: 'Jane Doe',
    email: '[email protected]',
  });

  // Read a record by _id property
  await repository.findById(doc._id);

  // Load every record with a single call
  for (const user of await repository.findAll()) {
    // Update existing records
    repository.update({
      ...user,
      lastSeenAt: Date.now(),
    });
  }
})();

Magic _id property

Each document gets an _id property assigned on read / write time, the identifier is the same as the document's path name without the table as prefix.

Ideology (Why)

S3 is a key value storage, but we always think about it as a file storage (as it's intended to be one). My problem was simple, the project I was working on had to store a set of JSON documents in a persistent and reliable storage, but it could not be a traditional database because the JSON files were the descriptors for the database. And S3 is a perfect solution for this, you can use it as a cheap and reliable solution to manage sets of data. But of course only if the query performance is not a problem!

Please don't try to create an e-commerce site with S3 as database, it will be slow and expensive for that kind of load, but if you wanna store and work with data which is not often needed but has to be available and reliable, then enjoy this repository.It will abstract the S3 finickiness away from you, and provide a super lightweight client to do so.

Also I am well aware of the AWS S3 SDK library, but it is 4.08 MB at the time of writing, while this library is 9kb as it is.

One more thing, don't forget to be awesome! ^.^

Versioning

From 1.0.0 to 1.1.0 the library will not follow the semantic versioning, the 1.1.0 is the first semantic release.