Created
September 1, 2020 00:02
-
-
Save dabit3/e9a4f8e7371712ff2f4a7e6d00ed07a3 to your computer and use it in GitHub Desktop.
Creating a user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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