0.2.0 • Published 3 years ago

dynamongo v0.2.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 years ago

Contributors Forks Stargazers Issues Apache-2.0 License LinkedIn

About The Project

Coming from MongoDB and moving towards DynamoDB, there are some abstractions that could make our lives easier. For instance, with DynamoDB, expression clauses have to be manually written as strings of instructions, while MongoDB allows for simple objects.

That's where this library comes in. It should mimick the basic MongoDB style of queries, not requiring any hand-written or generated conditions. Instead, pass in an object, Dynamongo will take care of sending it in the correct way to DynamoDB.

Note, this does not support any of the advanced MongoDB querying, instead, this simply allows you to use objects directly instead of having to write specific expressions.

Here's why:

  • Stop spending time on writing the same database boilerplate for handling dynamic DynamoDB expressions and filters
  • Use a library which takes care of this for you instead
  • Focus your time on actually writing your application instead of database utilities

Built With

This section should list any major frameworks that you built your project using. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Install the Dynamongo package into your project

npm install dynamongo

Usage

Get a Dynamongo instance, either through the singleton helper, or by instantiating it manually. Enter the region and optionally an object with supported options.

const db = Dynamongo.GetInstance('eu-west-1', {
	isVerbose: true,
	timestampsEnabled: true,
	timestampCreatedField: 'createdAt',
	timestampUpdatedField: 'updatedAt'
});

Now you are ready to use this instance for querying the database.

getByKey(table, keys)

const data = await db.getByKey('my-db-table', {customId: 'abc-123'});

updateByKey(table, keys, data)

const result = await db.updateByKey('my-db-table', {customId: 'abc-123'}, {newData: '123'});

deleteByKey(table, keys)

const result = await db.deleteByKey('my-db-table', {customId: 'abc-123'});

getWhere(table, data)

const data = await db.getWhere('my-db-table', {firstName: 'Kevin', lastName: 'Van Ryckegem'});

insert(table, data)

Note, by default, if data exists with the same keys, the data will be updated!

const result = await db.insert('my-db-table', {firstName: 'Kevin', lastName: 'Van Ryckegem'});

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

Contact

Kevin Van Ryckegem - @kevinvanryck

Project Link: https://github.com/kevinvr/dynamongo

Acknowledgements

Reserved for contributors!