本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB.PutItem方法的典型用法代码示例。如果您正苦于以下问题:Golang DynamoDB.PutItem方法的具体用法?Golang DynamoDB.PutItem怎么用?Golang DynamoDB.PutItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB
的用法示例。
在下文中一共展示了DynamoDB.PutItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fixtureUser
func fixtureUser(db *dynamodb.DynamoDB) error {
params := &dynamodb.PutItemInput{
Item: map[string]*dynamodb.AttributeValue{
"id": {
S: aws.String("uid123"),
},
"oauthid": {
S: aws.String("google:1234"),
},
"email": {
S: aws.String("[email protected]"),
},
"username": {
S: aws.String("username"),
},
"created_at": {
N: aws.String("123456789"),
},
"lastlogin": {
N: aws.String("123456789"),
},
},
TableName: aws.String("user"),
}
_, err := db.PutItem(params)
if err != nil {
return err
}
return nil
}
示例2: fixturePost
func fixturePost(db *dynamodb.DynamoDB) error {
params := &dynamodb.PutItemInput{
Item: map[string]*dynamodb.AttributeValue{
"id": {
S: aws.String("pid123"),
},
"uid": {
S: aws.String("uid123"),
},
"wall_id": {
S: aws.String("1"),
},
"message": {
S: aws.String("message"),
},
"created_at": {
N: aws.String(strconv.FormatInt(time.Now().UnixNano(), 10)),
},
},
TableName: aws.String("post"),
}
_, err := db.PutItem(params)
if err != nil {
return err
}
return nil
}
示例3: putResource
func putResource(svc *dynamodb.DynamoDB, resource Resource, tableName string) error {
item, err := dynamodbattribute.ConvertToMap(resource)
if err != nil {
return err
}
_, err = svc.PutItem(&dynamodb.PutItemInput{
Item: item,
TableName: aws.String(tableName),
})
return err
}
示例4: handleAdd
func handleAdd(subject string) {
fmt.Println("Add admin", subject)
var client *dynamodb.DynamoDB = dbutil.CreateDynamoDBClient()
params := &dynamodb.PutItemInput{
TableName: aws.String(ddl.AdminTableName),
Item: map[string]*dynamodb.AttributeValue{
"AdminID": {S: aws.String(subject)},
},
Expected: map[string]*dynamodb.ExpectedAttributeValue{
"AdminID": {Exists: aws.Bool(false)},
},
}
_, err := client.PutItem(params)
if err != nil {
fmt.Println(err.Error())
return
}
}
示例5: insertItem
func insertItem(db *dynamodb.DynamoDB) error {
var _, err = db.PutItem(putItemInput())
return err
}