本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB.BatchWriteItem方法的典型用法代码示例。如果您正苦于以下问题:Golang DynamoDB.BatchWriteItem方法的具体用法?Golang DynamoDB.BatchWriteItem怎么用?Golang DynamoDB.BatchWriteItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB
的用法示例。
在下文中一共展示了DynamoDB.BatchWriteItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UploadForumData
func UploadForumData(svc *dynamodb.DynamoDB) (*dynamodb.BatchWriteItemOutput, error) {
params := &dynamodb.BatchWriteItemInput{
RequestItems: map[string][]*dynamodb.WriteRequest{
"Forum": {
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Name": {
S: aws.String("Amazon DynamoDB"),
},
"Category": {
S: aws.String("Amazon Web Services"),
},
"Threads": {
N: aws.String("0"),
},
"Messages": {
N: aws.String("0"),
},
"Views": {
N: aws.String("1"),
},
},
},
},
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Name": {
S: aws.String("Amazon S3"),
},
"Category": {
S: aws.String("Amazon Web Services"),
},
"Threads": {
N: aws.String("0"),
},
},
},
},
},
},
}
return svc.BatchWriteItem(params)
}
示例2: UploadReplyData
func UploadReplyData(svc *dynamodb.DynamoDB) (*dynamodb.BatchWriteItemOutput, error) {
oneDayAgo := time.Now().AddDate(0, 0, -1).String()
sevenDaysAgo := time.Now().AddDate(0, 0, -7).String()
fourteenDaysAgo := time.Now().AddDate(0, 0, -14).String()
twentyOneDaysAgo := time.Now().AddDate(0, 0, -21).String()
params := &dynamodb.BatchWriteItemInput{
RequestItems: map[string][]*dynamodb.WriteRequest{
"Reply": {
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
S: aws.String("Amazon DynamoDB#DynamoDB Thread 1"),
},
"ReplyDateTime": {
S: aws.String(fourteenDaysAgo),
},
"Message": {
S: aws.String("DynamoDB Thread 1 Reply 2 text"),
},
"PostedBy": {
S: aws.String("User B"),
},
},
},
},
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
S: aws.String("Amazon DynamoDB#DynamoDB Thread 2"),
},
"ReplyDateTime": {
S: aws.String(twentyOneDaysAgo),
},
"Message": {
S: aws.String("DynamoDB Thread 2 Reply 3 text"),
},
"PostedBy": {
S: aws.String("User B"),
},
},
},
},
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
S: aws.String("Amazon DynamoDB#DynamoDB Thread 2"),
},
"ReplyDateTime": {
S: aws.String(sevenDaysAgo),
},
"Message": {
S: aws.String("DynamoDB Thread 2 Reply 2 text"),
},
"PostedBy": {
S: aws.String("User A"),
},
},
},
},
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
S: aws.String("Amazon DynamoDB#DynamoDB Thread 2"),
},
"ReplyDateTime": {
S: aws.String(oneDayAgo),
},
"Message": {
S: aws.String("DynamoDB Thread 2 Reply 1 text"),
},
"PostedBy": {
S: aws.String("User A"),
},
},
},
},
},
},
}
return svc.BatchWriteItem(params)
}
示例3: UploadProductCatalog
func UploadProductCatalog(svc *dynamodb.DynamoDB) (*dynamodb.BatchWriteItemOutput, error) {
params := &dynamodb.BatchWriteItemInput{
RequestItems: map[string][]*dynamodb.WriteRequest{
"ProductCatalog": {
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
N: aws.String("1101"),
},
"Title": {
S: aws.String("Book 101 Title"),
},
"ISBN": {
S: aws.String("111-1111111111"),
},
"Authors": {
SS: []*string{
aws.String("Author1"),
},
},
"Price": {
N: aws.String("2"),
},
"Dimensions": {
S: aws.String("8.5 x 11.0 x 0.5"),
},
"PageCount": {
N: aws.String("500"),
},
"InPublication": {
N: aws.String("1"),
},
"ProductCategory": {
S: aws.String("Book"),
},
},
},
},
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
N: aws.String("102"),
},
"Title": {
S: aws.String("Book 102 Title"),
},
"ISBN": {
S: aws.String("222-2222222222"),
},
"Authors": {
SS: []*string{
aws.String("Author1"),
aws.String("Author2"),
},
},
"Price": {
N: aws.String("20"),
},
"Dimensions": {
S: aws.String("8.5 x 11.0 x 0.8"),
},
"PageCount": {
N: aws.String("600"),
},
"InPublication": {
N: aws.String("1"),
},
"ProductCategory": {
S: aws.String("Book"),
},
},
},
},
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"Id": {
N: aws.String("103"),
},
"Title": {
S: aws.String("Book 103 Title"),
},
"ISBN": {
S: aws.String("333-3333333333"),
},
"Authors": {
SS: []*string{
aws.String("Author1"),
aws.String("Author2"),
},
},
"Price": {
N: aws.String("2000"),
},
"Dimensions": {
//.........这里部分代码省略.........