Skip to content

Instantly share code, notes, and snippets.

@jrevillas
Last active October 26, 2018 05:32
Show Gist options
  • Save jrevillas/9a7530c01a00fe9d0d45b16c0746e1d1 to your computer and use it in GitHub Desktop.
Save jrevillas/9a7530c01a00fe9d0d45b16c0746e1d1 to your computer and use it in GitHub Desktop.
const aws = require('aws-sdk');
const ddb = new aws.DynamoDB();
exports.handler = async (event) => {
const params = {
Item: {
OrderId: {S: '01CTN1N01N8E3QEQ926RM4QYFS'},
OrderInformation: {M: {}},
ShopId: {N: '0'}
},
ConditionExpression: 'attribute_not_exists(#id) AND attribute_not_exists(#shop)',
ExpressionAttributeNames: {
'#id': 'OrderId',
'#shop': 'ShopId'
},
ReturnConsumedCapacity: 'TOTAL',
TableName: 'StarbucksOrdersWithUlids'
};
const qParams = {
ExclusiveStartKey: {
OrderId: {S: '01CTN1N01N8E3QEQ926RM4QYFQ'},
ShopId: {N: '0'}
},
ExpressionAttributeValues: {
':v1': {N: '0'}
},
KeyConditionExpression: 'ShopId = :v1',
// Select: 'COUNT',
Limit: 3,
TableName: 'StarbucksOrdersWithUlids'
};
await ddb.query(qParams).promise()
// await ddb.putItem(params).promise()
.then(data => console.log(data))
//.then(data => console.log(data.Items.map(x => x.OrderId)))
.catch(err => console.log(err));
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!')
};
return response;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment