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

	// Construct the filter builder with a name and value.
	filt := expression.Name("Artist").Equal(expression.Value("No One You Know"))

	// Create the names list projection of names to project.
	proj := expression.NamesList(
		expression.Name("AlbumTitle"),
		expression.Name("SongTitle"),
	)

	// Using the filter and projections create a DynamoDB expression from the two.
	expr, err := expression.NewBuilder().
		WithFilter(filt).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}

	// Use the built expression to populate the DynamoDB Scan API input parameters.
	input := &dynamodb.ScanInput{
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		FilterExpression:          expr.Filter(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}

	result, err := svc.Scan(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 Filter Expression
//
// This example scans the entire Music table, and then narrows the results to songs
// by the artist "No One You Know". For each item, only the album title and song title
// are returned.
Using Filter Expression

This example scans the entire Music table, and then narrows the results to songs
by the artist "No One You Know". For each item, only the album title and song title
are returned.
// Using Filter Expression // // This example scans the entire Music table and then narrows the results to songs // by the artist " No One You Know " . For each item only the album title and song title // are returned .
func ExampleBuilder_WithFilter() {
	svc := dynamodb.New(session.New())
	filt := expression.Name("Artist").Equal(expression.Value("No One You Know"))
	proj := expression.NamesList(
		expression.Name("AlbumTitle"),
		expression.Name("SongTitle"),
	)
	expr, err := expression.NewBuilder().
		WithFilter(filt).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}
	input := &dynamodb.ScanInput{
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		FilterExpression:          expr.Filter(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}
	result, err := svc.Scan(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_WithFilter ( ) { svc := dynamodb . New ( session . New ( ) ) filt := expression . Name ( " " ) . Equal ( expression . Value ( " " ) ) proj := expression . NamesList ( expression . Name ( " " ) , expression . Name ( " " ) , ) expr , err := expression . NewBuilder ( ) . WithFilter ( filt ) . WithProjection ( proj ) . Build ( ) if err != nil { fmt . Println ( err ) } input := & dynamodb . ScanInput { ExpressionAttributeNames : expr . Names ( ) , ExpressionAttributeValues : expr . Values ( ) , FilterExpression : expr . Filter ( ) , ProjectionExpression : expr . Projection ( ) , TableName : aws . String ( " " ) , } result , err := svc . Scan ( 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 Filter Expression
Using Filter Expression
// Construct the filter builder with a name and value. // Create the names list projection of names to project. // Using the filter and projections create a DynamoDB expression from the two. // Use the built expression to populate the DynamoDB Scan API input parameters. // Print the error, cast err to awserr.Error to get the Code and // Message from an error.