tiny_ds 0.0.2 → 0.0.3.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +18 -15
- data/Rakefile +1 -1
- data/lib/tiny_ds/base.rb +28 -25
- data/lib/tiny_ds/base_tx.rb +4 -4
- data/lib/tiny_ds/low_ds.rb +14 -4
- data/lib/tiny_ds/property_definition.rb +14 -0
- data/lib/tiny_ds/query.rb +23 -1
- data/lib/tiny_ds/transaction.rb +37 -0
- data/lib/tiny_ds/version.rb +1 -1
- data/lib/tiny_ds.rb +25 -3
- data/spec/basic_spec.rb +212 -13
- data/spec/gae_spec.rb +86 -0
- data/spec/tx_spec.rb +82 -0
- metadata +7 -13
- data/lib/tiny_ds/base.rb~ +0 -115
- data/lib/tiny_ds/base_tx.rb~ +0 -180
- data/lib/tiny_ds/low_ds.rb~ +0 -80
- data/lib/tiny_ds/property_definition.rb~ +0 -54
- data/lib/tiny_ds/query.rb~ +0 -68
- data/lib/tiny_ds/validations.rb~ +0 -9
- data/lib/tiny_ds.rb~ +0 -2
- data/lib/tinyds.rb~ +0 -2
- data/spec/spec_helper.rb~ +0 -0
data/lib/tiny_ds/query.rb~
DELETED
@@ -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
|
data/lib/tiny_ds/validations.rb~
DELETED
data/lib/tiny_ds.rb~
DELETED
data/lib/tinyds.rb~
DELETED
data/spec/spec_helper.rb~
DELETED
File without changes
|