@knymbus/dynamo-query-builder
v0.1.19
Published
[npm-badge]: https://img.shields.io/npm/v/@knymbus/dynamo-query-builder.svg?style=flat-square [npm]: https://www.npmjs.org/package/@knymbus/dynamo-query-builder
Downloads
7
Readme
Dynamo Query Builder
This is a small and light weight library that is use to build out dynamodb query operations.
As it is known dynamodb have a serious black list of reserve key words that we often forgot when building our tables. However when the time comes to update or query your data you run into this weird snytax that we constanty have to research.
This lirary is here to take that headache away by writing the queries for you with just a few steps.
Install:
$ npm i @knymbus/dynano-query-builder
Usage
import { DynamoQueryBuilder, FilterOption } from "@knymbus/dynamo-query-builder"
const TABLENAME = "My-dynamo-table-name"
export const queryItems = async ()=>{
const queryBuilder = new DynamoQueryBuilder()
queryBuider
.setTableName(tableName)
..setQuery({
filter: {
fields: [
{
field: "Ast",
comparison: FilterOption.eq,
value: "some_status_id",
join: 'nd'
},
{
field: 'block',
comparison: FilterOption.eq,
value: "A",
join: "/"
},
{
field: "block",
comparison: FilterOption.eq,
value: "B",
join: null
}
],
key: {
field: "accId",
comparison: FilterOption.eq,
value: "partition-accId"
}
}
})
// async/await option
const result = await queryBuider.execute()
// or the promise way
queryBuider.execute().then(result=>{
console.log(result)
}).catch(err=>{
console.log(err)
})
}