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

fireball-db

v0.3.13

Published

a lightweight model wrapper for DynamoDB

Downloads

35

Readme

Fireball

A lightweight model wrapper for DynamoDB with syntax that sucks less.

Getting Started

Install Fireball:

npm install fireball-db --save

Overview

Fireball, in its simplest form, is a wrapper around the AWS SDK DynamoDB Document Client. The primary purpose of this library is to create model object to reflect a single DynamoDB table. The model object provides many useful additions such as unique ID generation, cleaner parameter syntax and promise based functions.

Usage

Import fireball

fireball = require 'fireball-db'

Creating a model object

The model object is a wrapper around the DocumentClient that simplify the parameter syntax to most functions and will automatically add the TableName parameter as needed.

User = fireball.model 'SomeDynamoTable'

Creating a model with custom extensions

User = fireball.model 'SomeDynamoTable',

  find_by_email: (email) ->
    ...

User.find_by_email('[email protected]').then (users) ->
  ...

Promises

All functions of the model object return Promises.

Information on Promises

Querying a table

User = ...
User.query(
  expression: '#field = :value'
  names: {'#field': 'name'}
  values: {':value': 'fred'}
).then (users) ->
  ...

Querying a table with specific index

User = ...
User.query(
  expression: '#field = :value'
  names: {'#field': 'name'}
  values: {':value': 'fred'}
  IndexName: 'secondary_index'
).then (users) ->
  ...

Scanning a table

User = ...
User.scan(
  expression: '#field = :value'
  names: {'#field': 'name'}
  values: {':value': 'fred'}
).then (users) ->
  ...

Getting an item

User = ...
key = email: '[email protected]'
User.get(key).then (user) ->
  ...

Getting an item by identifier

Wrapper around get that will use the managed identifier key.

User = ...
User.for_id('12312312321').then (user) ->
  ...

Putting an item

User = ...
User.put(first: 'John', last: 'Doe', email: '[email protected]').then (user) ->
  ...

Putting an item with condition expression

User = ...
user_data = first: 'John', last: 'Doe', email: '[email protected]'
condition = expression: '#field = :value', names: {'#field': 'name'}, values: {':value': 'fred'}

User.put(user_data, condition).then (user) ->
  ...

Inserting an item

Wrapper around put that will automatically add an identifier field and ensure uniqueness.

User = ...
User.insert(first: 'John', last: 'Doe', email: '[email protected]').then (user) ->
  ...

Updating an item

User = ...
key = email: '[email protected]'
User.insert(key, first: 'John', last: 'Doe').then (user) ->
  ...

Deleting an item by key

User = ...
key = email: '[email protected]'
User.delete(key).then (user) ->
  ...

Deleting an item

User = ...
user = email: '[email protected]', name: 'someone', ...
User.delete(item).then (user) ->
  ...

Get all items for keys (batchGet)

User = ...
keys = [
  {email: '[email protected]'}
  {email: '[email protected]'}
  {email: '[email protected]'}
]
User.for_keys(keys).then (users) ->
  ...

Get all items for identifiers

User = ...
ids = [
  '12121'
  '12122'
  '12123'
]
User.for_ids(ids).then (users) ->
  ...

Putting multiple items (batchWrite)

User = ...
items = [
  {first: 'John', last: 'Doe', email: '[email protected]'}
  {first: 'Jane', last: 'Doe', email: '[email protected]'}
  {first: 'Sally', last: 'Doe', email: '[email protected]'}
]
User.put_all(items).then (users) ->
  ...

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.