mweagle / Sparta

go microservices, powered by AWS Lambda
https://gosparta.io
MIT License
717 stars 48 forks source link

Support Custom ScanInput/QueryInput with Accessor.DynamoAccessor #142

Open Caoimhin89 opened 5 years ago

Caoimhin89 commented 5 years ago

Is there a way to pass in our own custom QueryInput or ScanInput to be used with the Accessor.DynamoAccessor or would it be possible to add this functionality?

Basically something like this:

func (svc *DynamoAccessor) Query(ctx context.Context,
        customInput *dynamodb.QueryInput // pass in customized QueryInput
    destObject interface{}) error {
    queryInput := customInput // assign customized QueryInput

    queryResult, queryResultErr := svc.dynamoSvc(ctx).QueryWithContext(ctx, queryInput)
    if queryResultErr != nil {
        return queryResultErr
    }
    return dynamodbattribute.UnmarshalMap(queryResult, destObject)
}
mweagle commented 5 years ago

Hi @Caoimhin89 - that seems like a very reasonable thing to add to a general DynamoDB wrapper. The accessor that's in Sparta is currently limited to a KeyValueAccessor pattern. If we added a Query function I'm not sure that would apply to all the providers. WDYT about embedding the base accessor and extending with the new functionality?

Caoimhin89 commented 5 years ago

@mweagle That makes sense.