dyna-moco
v0.2.1
Published
A small but useful set of helpers, making Dynamo more acute and less obtuse. (Member of the Federalies)
Downloads
4
Maintainers
Readme
DyanMoCo + MoCoQuery
DynamoDB is great but the way you interact with it is not really great. DynaMoco is small but mighty, wrapper that is strong enough to get what you want out of DynamoDB and gentle enough to act like bowling with bumpers on.
Writeen in Typescript it should help you with auto-complete etc - if that is of interest.
The DynaMoco Problem
- The API of Dyanmo has a steep learning curve.
- Its flexibiltiy creates too much complexity to comprehend at thge outset.
- Dynamoco optimizes for a few use-cases that seem noramtive, making those very easy.
- If you need to do the more complicated parts, it attempts to move out of the way.
The DynaMoco Solution
Use this package if:
- You need to just get going with DynamoDB
- You find the Dynamo API difficult and seemingly optimzed for AWS engineers and not it's users.
- You enjoy flexible streamlined modules.
Installation
npm install dynamoco
# or
yarn add dynamoco
Usage
There are two independent functions that work nicely together in dynamoco
.
The first is the gentle wrapper - dynamoco
The second is a nice query builder - mocoquery
Each of them cover some ground on the API surface area exposed by Dyanmo.
Get Item (Full Monty)
import {Dynamo} from 'aws-sdk'
import {dynamoco} from 'dynamoco'
import {credentials} from './credentials'
;(async ()=>{
const d = new Dyanmo({credentials})
const moco = dynamoco(d)
// using a table that is already available
const resutls = await moco.getItem('MyTable', {MyKey: 'SomeValue'})
console.log(results._Item)
/* {
MyKey: 'SomeValue',
numberValues: 1,
stringValues: 'strings are strings'
}
*/
})()
Using The Query Builder
import {Dynamo} from 'aws-sdk'
import {mocoquery} from 'dynamoco'
import {credentials} from './credentials'
;(async ()=>{
const d = new Dyanmo({credentials})
const queryParams = mocoquery('MyTable')
.select('*')
.where(['Year','>=',2020])
.extract()
// using the regular Dyanmo Client
const regularResults = await d.query(queryParams)
console.log('regularResults', regularResults.Items)
// using the regular Dyanmo Client
const ezResults = await dynamoco(d).query(queryParams)
console.log('ezResults', ezResults._Items)
})()
For more examples, please refer to the Documentation
Technical
Single dependency
By design, this module has a single, external, run-time dependency (aws-sdk
). And it uses a few other packages while running tests. It is a stated goal of the project to keep the dependencies as small as reasonable. (different than as small as possible)
Dependency
Codebase
This is a Typescript codebase, and aims to be relatively up to date with the latest version. Adopting new typescript version will likely comence after some hardening period, but hastened if a new language feature has been added that substantially supports this project.
Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Have a question? Ask it in an issue! We'd love to hear from you.
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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Community
See the Community Standards and Code of Conduct
Contact
Eric D Moore
Project Link: https://github.com/federalies/dynamoco
Acknowledgements & Credits
- Img Shields
- GitHub Pages
- https://github.com/RichardLitt/standard-readme
License
Distributed under the MIT License. See LICENSE
for more information.