Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@workgrid/dynamo-query-builder
Advanced tools
An abstraction layer for the AWS SDK DynamoDB to construct query parameters for various operations. Supports both DynamoDB and DocumentClient type clients.
Readme
An abstraction layer for the AWS SDK DynamoDB to construct query parameters for various operations. Supports both DynamoDB and DocumentClient type clients.
Operation | Supported? |
---|---|
Get | ✓ |
Query | ✓ |
Delete | ✓ |
Scan | ✓ |
Update | ✓ |
Put | ✓ |
Batch Get | x |
Batch Write | x |
Create Set | x |
Transact Get | x |
Transact Write | x |
Attributes | Supported? |
---|---|
Key | ✓ |
ExpressionAttributeNames | ✓ |
ExpressionAttributeValues | ✓ |
FilterExpression | ✓ |
IndexName | ✓ |
KeyConditionExpression | ✓ |
Limit | ✓ |
Item | ✓ |
ProjectionExpression | ✓ |
UpdateExpression | ✓ |
ConditionExpression | ✓ |
ExclusiveStartKey | ✓ |
ReturnConsumedCapacity | x |
ReturnItemCollectionMetrics | x |
ReturnValues | x |
ConsistentRead | x |
KeyConditions | x |
ScanIndexForward | x |
Select | x |
Segment | x |
TotalSegments | x |
ConditionalOperator | ~ |
AttributeUpdates | ~ |
QueryFilter | ~ |
ScanFilter | ~ |
AttributesToGet | ~ |
Expected | ~ |
An operation would be considered one of the functions that Dynamo provides, such as Get, Query, Put, Scan, etc
Examples of existing operations can be found in the operations directory.
Each of these operations are a single class being built up using a selection of attributes to make up it's functionality.
For example, the Get operation pulls in the following attributes;
This class exposes the set attribute functions using public access type, while keeping the get ones private by keeping them outside of the class entirely.
The get attributes are kept private, as they are only exposed and returned all together via the getConstructedQuery function.
Since the
private
andpublic
keywords are only honoured in Typescript prior to compilation; when using in a Javascript project, private methods and attributes are visibly and accessable. In order to hide clutter,internal
tags are used as a workaround for eachprivate
attribute.
Typically (But up to you), attribute set functions are chainable. Chainable function can be setup using the chainable utility, so that any attribute can be converted to this style, where it sees fit.
Each attribute's get function has been setup to return a spreadable object containing it's attribute(s), so the getConstructedQuery function can safely spread each attribute.
Once the operation class has been built, export the class in the main index file.
An attribute is one of the data objects that are expected to be present in the parameters object of an operation.
A list of all DocumentClient operation attributes can be found on the AWS documentation.
Each attribute can be constructed in any way you see fit, although, keep in consideration the design principles of the existing attributes in order to ensure consistency of expected behaviour;
Examples of existing attributes can be found in the attributes directory.
Typically, attributes consist of a Add/Set function and a Get function. Although, these can be named anything!
The attribute will modify it's property via the Add/Set function, and keep it in a generic state, where it will then be constructed into either DynamoDb or DocumentClient format when accessed via Get.
Sometimes, an attribute needs to modify the contents of another attribute.
For example, KeyConditionExpression needs to add to ExpressionAttributeValues.
In this case, make sure that the KeyConditionExpression only accesses and sets the ExpressionAttributeValues property through a parameter, and never returns another attribute's property, otherwise we introduce unmaintainable code!
See KeyConditionExpression for an example of this parameter passing.
FAQs
An abstraction layer for the AWS SDK DynamoDB to construct query parameters for various operations. Supports both DynamoDB and DocumentClient type clients.
The npm package @workgrid/dynamo-query-builder receives a total of 27 weekly downloads. As such, @workgrid/dynamo-query-builder popularity was classified as not popular.
We found that @workgrid/dynamo-query-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.