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

dynomite

v2.0.3

Published

Simple ORM for AWS DynamoDB

Downloads

24

Readme

Dynomite DynamoDB ORM

This package contains a basic ORM for using DynamoDB with CloudSearch.

It does not contain an application server. It is designed to be used in conjunction with your systems.

Installation:

 npm install dynomite

Usage

Defining your own objects is simple:

const Test = db.define({
	tableName: 'Test',
	key: '__id__',
	properties: {
		__id__: new db.types.StringProperty(),
		name: new db.types.StringProperty({verbose_name: 'My Name'}),
		numeric: new db.types.NumberProperty({verbose_name: 'Some Number'}),
		num_restricted: new db.types.NumberProperty({min: 1, max:10}),
		stringSet: new db.types.SetProperty({ type: String, verbose_name: 'A list of strings'}),
		numberSet: new db.types.SetProperty({ type: Number, verbose_name: 'A list of numbers'})
	}
});

Once you have an object, you can create new instances of it, and save it:

const obj = new Test('foo');
obj.name = 'My Object Name';
obj.numeric = 10;
obj.stringSet = ['foo', 'bar', 'biz'];
obj.save(function(err, data){
	console.log('Object was saved!');
});

Test

Run the test case with:

 npm test

History

As of version 0.2.0, Dynomite Supports Transactional History tracking.

This lets you track History for any given object and create a new History object anytime that object is changed. Anytime the save() function is called, it automatically creates the History object. This contains the "new" object in a simplified JSON form. If you use a lookup, batchLookup, scan, or query function, this object will also contain the "original" object.

Additional parameters may be passed along with a save operation, Typically this will include things like the User that made the change, as well as a Comment. You can also include a "transaction_id", which, when combined with a GSI, can be used to determine all changes that happened in a given "transaction".

To enable this functionality, you must first create a DynamoDB table with HashKey of "obj" (S) and RangeKey of "ts" (N). You should also add a GSI of "transaction_id" if you wish to use that feature.

Then you can enable History tracking on each individual object you wish to have tracked, by simply adding "track_history: true" to the definitions:

db.create({
	track_history: true

Each object will also need a $type and $id so you can properly reference the object that was changed.

Some Special parameters may also be sent along with the save() function. By default $user, $comment, and $transaction_id are all supported in the standard arguments of an object, but you can also pass along any arguments you want to the "log" property of the save function:

obj.$comment = 'This is why I made this change';
obj.$user = { $type: 'User', $id: 'my-user-id' };
obj.save(cb, expected, { 'url': 'http://some_url', 'method', 'POST' })