Exemplo n.º 1
0
func batchAddPosts(client *dynago.Client, userId, start, end int) error {
	// Add some posts
	writer := client.BatchWrite()
	for i := start; i < end; i++ {
		writer = writer.Put("Posts", dynago.Document{"UserId": userId, "Dated": i})
	}
	_, err := writer.Execute()
	return err
}
Exemplo n.º 2
0
func ExampleClient_BatchWrite(client *dynago.Client) {
	record1 := dynago.Document{"Id": 1, "Name": "Person1"}
	record2 := dynago.Document{"Id": 2, "Name": "Person2"}

	// We can put and delete at the same time to multiple tables.
	client.BatchWrite().
		Put("Table1", record1, record2).
		Put("Table2", dynago.Document{"Name": "Other"}).
		Delete("Table2", dynago.HashKey("Id", 42)).
		Execute()
}