Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function genericRecordUpdate(esClient, id, doc, index, type, parent) {
if (!doc) throw new Error('Nothing to update. Make sure doc argument has a value');
const body = cloneDeep(doc);
body.timestamp = Date.now();
const params = {
body,
id,
index,
type,
refresh: inTestMode()
};
if (parent) params.parent = parent;
// adding or replacing record to ES
const actualEsClient = esClient || (await Search.es());
return actualEsClient.index(params);
}
async function genericRecordUpdate(esClient, id, doc, index, type, parent) {
if (!esClient) {
esClient = await Search.es();
}
if (!doc) {
throw new Error('Nothing to update. Make sure doc argument has a value');
}
doc.timestamp = Date.now();
const params = {
index,
type,
id,
refresh: inTestMode(),
body: doc
};
if (parent) {
params.parent = parent;
}
// adding or replacing record to ES
return esClient.index(params);
}
if (range) {
params.KeySchema.push({
AttributeName: range.name,
KeyType: 'RANGE'
});
params.AttributeDefinitions.push({
AttributeName: range.name,
AttributeType: range.type
});
}
const output = await aws.dynamodb().createTable(params).promise();
await aws.dynamodb().waitFor('tableExists', { TableName: tableName }).promise();
if (!inTestMode()) await enableStream(tableName);
return output;
}