/
account.rb
40 lines (35 loc) · 860 Bytes
/
account.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Models
class Account
include DataMapper::Resource
storage_names[:default] = 'accounts'
property :id, Serial
property :name, String
property :email, String
property :password, Text
property :player_password, Text
has n, :players
def get_by_name(name)
Models::Account.first(:name => name)
end
# def initialize
# super
#
# @table_name = "accounts"
# end
#
# def get_by_name(name)
# query = "select * from accounts where name = ?"
# @sql.one(query, name)
# end
#
# def get_players(id)
# query = "select * from players where account_id = ?"
# @sql.get(query, id)
# end
#
# def get_by_player_id(id)
# query = "select * from accounts where id = (select account_id from players where id = ?)"
# @sql.one(query, id)
# end
end
end