func ExampleBuilder_WithKeyCondition() {
	svc := dynamodb.New(session.New())

	// Construct the Key condition builder
	keyCond := expression.Key("Artist").Equal(expression.Value("No One You Know"))

	// Create the project expression builder with a names list.
	proj := expression.NamesList(expression.Name("SongTitle"))

	// Combine the key condition, and projection together as a DynamoDB expression
	// builder.
	expr, err := expression.NewBuilder().
		WithKeyCondition(keyCond).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}

	// Use the built expression to populate the DynamoDB Query's API input
	// parameters.
	input := &dynamodb.QueryInput{
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		KeyConditionExpression:    expr.KeyCondition(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}

	result, err := svc.Query(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
// Using Key Condition Expression
//
// This example queries items in the Music table. The table has a partition key and
// sort key (Artist and SongTitle), but this query only specifies the partition key
// value. It returns song titles by the artist named "No One You Know".
Using Key Condition Expression

This example queries items in the Music table. The table has a partition key and
sort key (Artist and SongTitle), but this query only specifies the partition key
value. It returns song titles by the artist named "No One You Know".
// Using Key Condition Expression // // This example queries items in the Music table . The table has a partition key and // sort key ( Artist and SongTitle ) but this query only specifies the partition key // value . It returns song titles by the artist named " No One You Know " .
func ExampleBuilder_WithKeyCondition() {
	svc := dynamodb.New(session.New())
	keyCond := expression.Key("Artist").Equal(expression.Value("No One You Know"))
	proj := expression.NamesList(expression.Name("SongTitle"))
	expr, err := expression.NewBuilder().
		WithKeyCondition(keyCond).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}
	input := &dynamodb.QueryInput{
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		KeyConditionExpression:    expr.KeyCondition(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}
	result, err := svc.Query(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			fmt.Println(err.Error())
		}
		return
	}
	fmt.Println(result)
}
func ExampleBuilder_WithKeyCondition ( ) { svc := dynamodb . New ( session . New ( ) ) keyCond := expression . Key ( " " ) . Equal ( expression . Value ( " " ) ) proj := expression . NamesList ( expression . Name ( " " ) ) expr , err := expression . NewBuilder ( ) . WithKeyCondition ( keyCond ) . WithProjection ( proj ) . Build ( ) if err != nil { fmt . Println ( err ) } input := & dynamodb . QueryInput { ExpressionAttributeNames : expr . Names ( ) , ExpressionAttributeValues : expr . Values ( ) , KeyConditionExpression : expr . KeyCondition ( ) , ProjectionExpression : expr . Projection ( ) , TableName : aws . String ( " " ) , } result , err := svc . Query ( input ) if err != nil { if aerr , ok := err . ( awserr . Error ) ; ok { switch aerr . Code ( ) { case dynamodb . ErrCodeProvisionedThroughputExceededException : fmt . Println ( dynamodb . ErrCodeProvisionedThroughputExceededException , aerr . Error ( ) ) case dynamodb . ErrCodeResourceNotFoundException : fmt . Println ( dynamodb . ErrCodeResourceNotFoundException , aerr . Error ( ) ) case dynamodb . ErrCodeInternalServerError : fmt . Println ( dynamodb . ErrCodeInternalServerError , aerr . Error ( ) ) default : fmt . Println ( aerr . Error ( ) ) } } else { fmt . Println ( err . Error ( ) ) } return } fmt . Println ( result ) }
Using Key Condition Expression
Using Key Condition Expression
// Construct the Key condition builder // Create the project expression builder with a names list. // Combine the key condition, and projection together as a DynamoDB expression // builder. // Use the built expression to populate the DynamoDB Query's API input // parameters. // Print the error, cast err to awserr.Error to get the Code and // Message from an error.