@knymbus/dynamo-query-builder
TypeScript icon, indicating that this package has built-in type declarations

0.1.19 • Public • Published

Dynamo Query Builder npm package

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)
            })
}

Readme

Keywords

none

Package Sidebar

Install

npm i @knymbus/dynamo-query-builder

Weekly Downloads

1

Version

0.1.19

License

ISC

Unpacked Size

88.3 kB

Total Files

69

Last publish

Collaborators

  • kaytalium