本文整理汇总了Golang中github.com/underarmour/dynago.Client.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.CreateTable方法的具体用法?Golang Client.CreateTable怎么用?Golang Client.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/underarmour/dynago.Client
的用法示例。
在下文中一共展示了Client.CreateTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleClient_CreateTable_basic
func ExampleClient_CreateTable_basic(client *dynago.Client) {
// NewCreateRequest creates a table with simple defaults.
// You can use chaining to set the hash and range keys.
table1 := schema.NewCreateRequest("TableName").
HashKey("UserId", schema.Number).
RangeKey("Date", schema.String)
table1.ProvisionedThroughput.ReadCapacityUnits = 45
client.CreateTable(table1)
}
示例2: makeTables
func makeTables(t *testing.T, client *dynago.Client) {
complexIndexed := complexIndexedSchema()
hashTable := schema.NewCreateRequest("Person").HashKey("Id", schema.Number)
hashRange := schema.NewCreateRequest("Posts").
HashKey("UserId", schema.Number).
RangeKey("Dated", schema.Number)
tables := []*schema.CreateRequest{hashTable, hashRange, complexIndexed}
for _, table := range tables {
_, err := client.CreateTable(table)
if err != nil {
if e, ok := err.(*dynago.Error); ok && e.Type == dynago.ErrorResourceInUse {
continue
}
panic(err)
}
}
}
示例3: ExampleClient_CreateTable_full
func ExampleClient_CreateTable_full(client *dynago.Client) {
// Most of the time we don't need the full syntax for making create requests
// It's shown here mostly for purpose of documentation
req := &schema.CreateRequest{
TableName: "PersonalPages",
AttributeDefinitions: []schema.AttributeDefinition{
{"UserId", schema.Number},
{"Title", schema.String},
},
KeySchema: []schema.KeySchema{
{"UserId", schema.HashKey},
{"Title", schema.RangeKey},
},
ProvisionedThroughput: schema.ProvisionedThroughput{
ReadCapacityUnits: 45,
WriteCapacityUnits: 72,
},
}
if response, err := client.CreateTable(req); err == nil {
fmt.Printf("table created, status %s", response.TableDescription.TableStatus)
}
}