aws-sdk#DynamoDB TypeScript Examples
The following examples show how to use
aws-sdk#DynamoDB.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: controller.ts From serverless-dynamodb-api-boilerplate with MIT License | 6 votes |
createController = async (
event: APIGatewayProxyEvent,
documentClient: DynamoDB.DocumentClient
) => {
// Parse string to verified request schema model
const input: Thing = JSON.parse(event.body);
const item = {
id: uuid(),
status: input.status || 'OK',
date_added: (+new Date()).toString(),
name: input.name,
};
const params = ThingModel.put(item);
await documentClient.put(params).promise();
return item;
}
Example #2
Source File: client.ts From dynamodb-instagram with MIT License | 6 votes |
getClient = (): DynamoDB => {
if (client) return client
client = new DynamoDB({
httpOptions: {
connectTimeout: 1000,
timeout: 1000
}
})
return client
}
Example #3
Source File: attribute.ts From dyngoose with ISC License | 6 votes |
/**
* Convert the given value for this attribute to a DynamoDB AttributeValue
*/
toDynamo(value: Value | null): DynamoDB.AttributeValue | null {
// if there is no value, inject the default value for this attribute
if (value == null || isTrulyEmpty(value)) {
// if we have no value, allow the manipulateWrite a chance to provide a value
if (typeof this.metadata.manipulateWrite === 'function') {
return this.metadata.manipulateWrite(null, null, this)
} else {
return null
}
}
// if there is no value, do not not return an empty DynamoDB.AttributeValue
if (value == null) {
if (this.metadata.required === true) {
throw new ValidationError('Required value missing: ' + this.name)
}
return null
}
if (typeof this.metadata.validate === 'function' && !this.metadata.validate(value)) {
throw new ValidationError('Validation failed: ' + this.name)
}
const attributeValue = this.type.toDynamo(value, this)
if (typeof this.metadata.manipulateWrite === 'function') {
return this.metadata.manipulateWrite(attributeValue, value, this)
} else {
return attributeValue
}
}
Example #4
Source File: Alias.ts From heimdall with MIT License | 6 votes |
// Utils
private static generateGetParams(
aliasValue: string
): DynamoDB.DocumentClient.GetItemInput {
return {
TableName: config.tableName,
Key: {
alias: aliasValue
}
};
}
Example #5
Source File: 4-fix-ttl.ts From office-booker with MIT License | 6 votes |
fixTtl = async (config: Config) => {
const mapper = new DataMapper({
client: new DynamoDB(config.dynamoDB),
tableNamePrefix: config.dynamoDBTablePrefix,
});
await scanAndFix(mapper, BookingsModel);
await scanAndFix(mapper, OfficeBookingModel);
await scanAndFix(mapper, UserBookingsModel);
}
Example #6
Source File: DynamoDB.ts From serverless-dynamodb-api-boilerplate with MIT License | 5 votes |
documentClient = new DynamoDB.DocumentClient({
service: new DynamoDB({
endpoint: getEndpoint(),
region: getRegion()
})
})
Example #7
Source File: base.ts From dynamodb-instagram with MIT License | 5 votes |
public keys(): DynamoDB.Key {
return {
PK: { S: this.pk },
SK: { S: this.sk }
}
}
Example #8
Source File: sdk-calls.ts From amplify-codegen with Apache License 2.0 | 5 votes |
getDDBTable = async (tableName: string, region: string) => {
const service = new DynamoDB({ region });
return await service.describeTable({ TableName: tableName }).promise();
}
Example #9
Source File: batch-get.ts From dyngoose with ISC License | 5 votes |
public setConnection(dynamo: DynamoDB): this {
this.dynamo = dynamo
return this
}