Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sbstjn/sqs-object
Convert JavaScript objects to SQS Meta Attributes
https://github.com/sbstjn/sqs-object
aws mapping object sqs
Last synced: 28 days ago
JSON representation
Convert JavaScript objects to SQS Meta Attributes
- Host: GitHub
- URL: https://github.com/sbstjn/sqs-object
- Owner: sbstjn
- License: mit
- Created: 2017-03-03T22:34:33.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-04T13:43:46.000Z (almost 8 years ago)
- Last Synced: 2024-11-09T20:45:02.160Z (3 months ago)
- Topics: aws, mapping, object, sqs
- Language: JavaScript
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sqs-object
[![npm](https://img.shields.io/npm/v/sqs-object.svg)](https://www.npmjs.com/package/sqs-object)
[![license](https://img.shields.io/github/license/sbstjn/sqs-object.svg)](https://github.com/sbstjn/sqs-object/blob/master/LICENSE.md)
[![CircleCI](https://img.shields.io/circleci/project/github/sbstjn/sqs-object/master.svg)](https://circleci.com/gh/sbstjn/sqs-object)Convert **JavaScript** objects to **SQS Meta** attributes as *vice verse*.
## Installation
```bash
$ > npm install sqs-object --save
```## Usage
```js
const sqsObject = require('sqs-object');
```## Mapping
First define a mapping between the JavaScript object and the SQS Meta Attributes like this:
```js
const mapping = [
{
objectKey: 'id',
sqsKey: 'ID',
sqsType: 'Number'
},
{
objectKey: 'name',
sqsKey: 'Name',
sqsType: 'String'
},
{
objectKey: 'age',
sqsKey: 'Age',
sqsType: 'Number'
}
];
```## Object to Meta Attributes
```js
const meta = sqsObject.Meta({
id: 12,
name: 'Paul',
age: 45
}, mapping);
``````json
{
"ID": {
"DataType": "Number",
"StringValue": "12"
},
"Name": {
"DataType": "String",
"StringValue": "Paul"
},
"Age": {
"DataType": "Number",
"StringValue": "45"
}
}
```## Meta Attributes to Object
```js
const object = sqsObject.Object({
ID: {
DataType: 'Number',
StringValue: '12'
},
Name: {
DataType: 'String',
StringValue: 'Paul'
},
Age: {
DataType: 'Number',
StringValue: '45'
}
}, mapping);
``````json
{
"id": 12,
"name": "Paul",
"age": 45
}
```## License
Feel free to use the code, it's released using the [MIT license](https://github.com/sbstjn/sqs-object/blob/master/LICENSE.md).
## Contributors
- [Sebastian Müller](https://sbstjn.com)