本文整理汇总了Golang中github.com/underarmour/dynago.Client.PutItem方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.PutItem方法的具体用法?Golang Client.PutItem怎么用?Golang Client.PutItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/underarmour/dynago.Client
的用法示例。
在下文中一共展示了Client.PutItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Example_marshaling
func Example_marshaling(client *dynago.Client) {
type MyStruct struct {
Id int64
Name string
Description string
Tags []string
Address struct {
City string
State string
}
}
var data MyStruct
doc := dynago.Document{
// Basic fields like numbers and strings get marshaled automatically
"Id": data.Id,
"Name": data.Name,
"Description": data.Description,
// StringSet is compatible with []string so we can simply cast it
"Tags": dynago.StringSet(data.Tags),
// We don't automatically marshal structs, nest it in a document
"Address": dynago.Document{
"City": data.Address.City,
"State": data.Address.State,
},
}
client.PutItem("Table", doc).Execute()
}
示例2: ExampleClient_PutItem
func ExampleClient_PutItem(client *dynago.Client) {
doc := dynago.Document{
"Id": 42,
"Name": "Bob",
"Address": dynago.Document{
"City": "Boston",
"State": "MA",
},
}
_, err := client.PutItem("Person", doc).Execute()
if err != nil {
fmt.Printf("PUT failed: %v", err)
}
}