36. class Book < AWS::Record::Base
string_attr :title
end
Book.new(:title => 'スベらないプレゼン').save
Book.where('title like ?', '%プレゼン%').count
$ rails generate scaffold_controller Book title:string
config/routes.rb:
Myapp::Application.routes.draw do
resources :books
end
http://aws.amazon.com/articles/8621639827664165 より
37. class Book < AWS::Record::Base
string_attr :title
end
Book.new(:title => 'スベらないプレゼン').save
Railsと違和感なしに
Book.where('title like ?', '%プレゼン%').count
統合できる!
$ rails generate scaffold_controller Book title:string
config/routes.rb:
Myapp::Application.routes.draw do
resources :books
end
http://aws.amazon.com/articles/8621639827664165 より
41. @DynamoDBTable(tableName = "BookTable")
public class Book {
private Long id;
private String title;
@DynamoDBHashKey
public Long getId() {
" return this.id;
}
@DynamoDBAttribute(attributeName = "title")
public String getTitle() {
" return this.title;
}
// 以下、setter
}
42. 使用例
(DynamoDBMapper)
AWSCredentials cred = new BasicAWSCredentials(
"アクセスキ", "シークレットキー");
AmazonDynamoDB db = new AmazonDynamoDBClient(cred);
DynamoDBMapper mapper = new DynamoDBMapper(db);
Long key = 105L;
Book book = mapper.load(Book.class, key);
book.setTitle("スベらないプレゼン");
mapper.save(book);
mapper.delete(book);
48. 使用例
(SimpleDBMapper)
AWSCredentials cred = new BasicAWSCredentials(
"アクセスキ", "シークレットキー");
AmazonSimpleDB db = new AmazonSimpleDBClient(cred);
SimpleDBMapper mapper = new SimpleDBMapper(db);
Long key = 105L;
Book book = mapper.load(Book.class, key);
book.setTitle("スベらないプレゼン");
mapper.save(book);
mapper.delete(book);