tiny_ds 0.0.2 → 0.0.3.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,68 +0,0 @@
1
- module TinyDS
2
- class Query
3
- def initialize(model_class)
4
- @model_class = model_class
5
- @q = AppEngine::Datastore::Query.new(@model_class.kind)
6
- end
7
- def ancestor(anc)
8
- anc = case anc
9
- when Base; anc.key
10
- when String; LowDS::KeyFactory.stringToKey(anc)
11
- when AppEngine::Datastore::Key; anc
12
- else raise "unknown type. anc=#{anc.inspect}"
13
- end
14
- @q.set_ancestor(anc)
15
- self
16
- end
17
- def filter(name, operator, value)
18
- @q.filter(name, operator, value)
19
- self
20
- end
21
- def sort(name, dir=:asc)
22
- direction = {
23
- :asc => AppEngine::Datastore::Query::ASCENDING,
24
- :desc => AppEngine::Datastore::Query::DESCENDING
25
- }[dir]
26
- @q.sort(name, direction)
27
- self
28
- end
29
- def keys_only
30
- @q.java_query.setKeysOnly
31
- self
32
- end
33
-
34
- def count #todo(tx=nil)
35
- @q.count
36
- end
37
- def one #todo(tx=nil)
38
- @model_class.new_from_entity(@q.entity)
39
- end
40
- def all(opts={}) #todo(tx=nil)
41
- models = []
42
- @q.each(opts) do |entity|
43
- models << @model_class.new_from_entity(entity)
44
- end
45
- models
46
- end
47
- def each(opts={}) #todo(tx=nil)
48
- @q.each(opts) do |entity|
49
- yield(@model_class.new_from_entity(entity))
50
- end
51
- end
52
- def collect(opts={}) #todo(tx=nil)
53
- collected = []
54
- @q.each(opts) do |entity|
55
- collected << yield(@model_class.new_from_entity(entity))
56
- end
57
- collected
58
- end
59
- def keys(opts={}) #todo(tx=nil)
60
- keys = []
61
- self.keys_only
62
- @q.each(opts) do |entity|
63
- keys << entity.key
64
- end
65
- keys
66
- end
67
- end
68
- end
@@ -1,9 +0,0 @@
1
-
2
- module TinyDS
3
- module Validations
4
- def save
5
- end
6
- def save!
7
- end
8
- end
9
- end
data/lib/tiny_ds.rb~ DELETED
@@ -1,2 +0,0 @@
1
- module TinyDS
2
- end
data/lib/tinyds.rb~ DELETED
@@ -1,2 +0,0 @@
1
- module TinyDs
2
- end
data/spec/spec_helper.rb~ DELETED
File without changes