Skip to content

Instantly share code, notes, and snippets.

@dabit3
Created September 1, 2020 00:02
Show Gist options
  • Save dabit3/e9a4f8e7371712ff2f4a7e6d00ed07a3 to your computer and use it in GitHub Desktop.
Save dabit3/e9a4f8e7371712ff2f4a7e6d00ed07a3 to your computer and use it in GitHub Desktop.
Creating a user
const AWS = require('aws-sdk')
const docClient = new AWS.DynamoDB.DocumentClient()
async function createUser(user) {
const params = {
TableName: "AppSyncUserTable",
Item: user
}
// user should look like this: user = { id: "3", name: "Chris", location: "Canada" }
try {
await docClient.put(params).promise()
return user
} catch (err) {
console.log('DynamoDB error: ', err)
}
}
module.exports = createUser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment