Created
November 5, 2019 03:00
-
-
Save radzionc/1c30bbd1662cc3771b273d1f664c2dc9 to your computer and use it in GitHub Desktop.
This file contains 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 { documentClient, setNewValue, mergedParams, searchByKeyParams, projectionExpression } = require('./utils/db') | |
const { TABLE_NAME } = require('./constants/db') | |
const defaultParams = id => ({ | |
TableName: TABLE_NAME.USERS, | |
Key: { id } | |
}) | |
const getByEmail = (email, attributes = undefined) => | |
documentClient | |
.scan( | |
mergedParams( | |
{ TableName: TABLE_NAME.USERS }, | |
searchByKeyParams('email', email), | |
projectionExpression(attributes) | |
) | |
) | |
.promise() | |
.then(data => data.Items[0]) | |
const emails = [] | |
const ignore = async () => { | |
await Promise.all(emails.map(async email => { | |
const { id } = await getByEmail(email, ['id']) | |
await setNewValue(defaultParams(id), 'ignorePomodoroNews', true) | |
})) | |
} | |
ignore() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment