dynamo integration

This commit is contained in:
Martin McKeaveney 2021-01-15 13:24:36 +00:00
parent a7f9e2fb8f
commit 6d5dc7592e
2 changed files with 64 additions and 9 deletions

View File

@ -50,7 +50,7 @@
<Spacer medium />
{#if query}
{#if query?.parameters.length > 0}
<ParameterBuilder
bind:customParams={parameters.queryParams}
parameters={query.parameters}

View File

@ -18,25 +18,56 @@ const SCHEMA = {
},
},
query: {
create: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
customisable: true,
},
},
},
read: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS,
fields: {
Table: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
Index: {
index: {
type: FIELD_TYPES.STRING,
},
KeyConditionExpression: {
type: FIELD_TYPES.STRING,
customisable: true,
},
ExpressionAttributeNames: {
type: FIELD_TYPES.STRING,
},
ExpressionAttributeValues: {
},
update: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
customisable: true,
},
},
},
delete: {
"Dynamo Partition Key": {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
key: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
@ -55,12 +86,36 @@ class DynamoDBIntegration {
AWS.config.update(this.config)
}
async create(query) {
const response = await this.client.query({
TableName: query.table,
Item: query.json,
})
return response
}
async read(query) {
const response = await this.client.query({
TableName: query.Table,
KeyConditionExpression: query.KeyConditionExpression,
ExpressionAttributeNames: query.ExpressionAttributeNames,
ExpressionAttributeValues: query.ExpressionAttributeValues,
...query.json,
})
return response
}
async update(query) {
const response = await this.client.query({
TableName: query.Table,
...query.json,
})
return response
}
async delete(query) {
const response = await this.client.query({
TableName: query.Table,
Key: {
id: query.key,
},
})
return response
}