Sparta icon indicating copy to clipboard operation
Sparta copied to clipboard

Support Custom ScanInput/QueryInput with Accessor.DynamoAccessor

Open Caoimhin89 opened this issue 5 years ago • 2 comments

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)
}

Caoimhin89 avatar May 19 '19 18:05 Caoimhin89

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?

mweagle avatar May 21 '19 13:05 mweagle

@mweagle That makes sense.

Caoimhin89 avatar May 21 '19 13:05 Caoimhin89