Class: Appwrite::Query
- Inherits:
-
Object
- Object
- Appwrite::Query
- Defined in:
- lib/appwrite/query.rb
Class Method Summary collapse
- .and(queries) ⇒ Object
- .between(attribute, start, ending) ⇒ Object
- .contains(attribute, value) ⇒ Object
- .created_after(value) ⇒ Object
- .created_before(value) ⇒ Object
- .created_between(start, ending) ⇒ Object
- .crosses(attribute, values) ⇒ Object
- .cursor_after(id) ⇒ Object
- .cursor_before(id) ⇒ Object
- .distance_equal(attribute, values, distance, meters = true) ⇒ Object
- .distance_greater_than(attribute, values, distance, meters = true) ⇒ Object
- .distance_less_than(attribute, values, distance, meters = true) ⇒ Object
- .distance_not_equal(attribute, values, distance, meters = true) ⇒ Object
- .ends_with(attribute, value) ⇒ Object
- .equal(attribute, value) ⇒ Object
- .greater_than(attribute, value) ⇒ Object
- .greater_than_equal(attribute, value) ⇒ Object
- .intersects(attribute, values) ⇒ Object
- .is_not_null(attribute) ⇒ Object
- .is_null(attribute) ⇒ Object
- .less_than(attribute, value) ⇒ Object
- .less_than_equal(attribute, value) ⇒ Object
- .limit(limit) ⇒ Object
- .not_between(attribute, start, ending) ⇒ Object
- .not_contains(attribute, value) ⇒ Object
- .not_crosses(attribute, values) ⇒ Object
- .not_ends_with(attribute, value) ⇒ Object
- .not_equal(attribute, value) ⇒ Object
- .not_intersects(attribute, values) ⇒ Object
- .not_overlaps(attribute, values) ⇒ Object
- .not_search(attribute, value) ⇒ Object
- .not_starts_with(attribute, value) ⇒ Object
- .not_touches(attribute, values) ⇒ Object
- .offset(offset) ⇒ Object
- .or(queries) ⇒ Object
- .order_asc(attribute) ⇒ Object
- .order_desc(attribute) ⇒ Object
- .order_random ⇒ Object
- .overlaps(attribute, values) ⇒ Object
- .search(attribute, value) ⇒ Object
- .select(attributes) ⇒ Object
- .starts_with(attribute, value) ⇒ Object
- .touches(attribute, values) ⇒ Object
- .updated_after(value) ⇒ Object
- .updated_before(value) ⇒ Object
- .updated_between(start, ending) ⇒ Object
Instance Method Summary collapse
-
#initialize(method, attribute = nil, values = nil) ⇒ Query
constructor
A new instance of Query.
- #to_json(*args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(method, attribute = nil, values = nil) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/appwrite/query.rb', line 5 def initialize(method, attribute = nil, values = nil) @method = method @attribute = attribute if values != nil if values.is_a?(Array) @values = values else @values = [values] end end end |
Class Method Details
.and(queries) ⇒ Object
163 164 165 |
# File 'lib/appwrite/query.rb', line 163 def and(queries) return Query.new("and", nil, queries.map { |query| JSON.parse(query) }).to_s end |
.between(attribute, start, ending) ⇒ Object
63 64 65 |
# File 'lib/appwrite/query.rb', line 63 def between(attribute, start, ending) return Query.new("between", attribute, [start, ending]).to_s end |
.contains(attribute, value) ⇒ Object
111 112 113 |
# File 'lib/appwrite/query.rb', line 111 def contains(attribute, value) return Query.new("contains", attribute, value).to_s end |
.created_after(value) ⇒ Object
139 140 141 |
# File 'lib/appwrite/query.rb', line 139 def created_after(value) return greater_than("$createdAt", value) end |
.created_before(value) ⇒ Object
135 136 137 |
# File 'lib/appwrite/query.rb', line 135 def created_before(value) return less_than("$createdAt", value) end |
.created_between(start, ending) ⇒ Object
143 144 145 |
# File 'lib/appwrite/query.rb', line 143 def created_between(start, ending) return between("$createdAt", start, ending) end |
.crosses(attribute, values) ⇒ Object
191 192 193 |
# File 'lib/appwrite/query.rb', line 191 def crosses(attribute, values) return Query.new("crosses", attribute, [values]).to_s end |
.cursor_after(id) ⇒ Object
99 100 101 |
# File 'lib/appwrite/query.rb', line 99 def cursor_after(id) return Query.new("cursorAfter", nil, id).to_s end |
.cursor_before(id) ⇒ Object
95 96 97 |
# File 'lib/appwrite/query.rb', line 95 def cursor_before(id) return Query.new("cursorBefore", nil, id).to_s end |
.distance_equal(attribute, values, distance, meters = true) ⇒ Object
167 168 169 |
# File 'lib/appwrite/query.rb', line 167 def distance_equal(attribute, values, distance, meters = true) return Query.new("distanceEqual", attribute, [[values, distance, meters]]).to_s end |
.distance_greater_than(attribute, values, distance, meters = true) ⇒ Object
175 176 177 |
# File 'lib/appwrite/query.rb', line 175 def distance_greater_than(attribute, values, distance, meters = true) return Query.new("distanceGreaterThan", attribute, [[values, distance, meters]]).to_s end |
.distance_less_than(attribute, values, distance, meters = true) ⇒ Object
179 180 181 |
# File 'lib/appwrite/query.rb', line 179 def distance_less_than(attribute, values, distance, meters = true) return Query.new("distanceLessThan", attribute, [[values, distance, meters]]).to_s end |
.distance_not_equal(attribute, values, distance, meters = true) ⇒ Object
171 172 173 |
# File 'lib/appwrite/query.rb', line 171 def distance_not_equal(attribute, values, distance, meters = true) return Query.new("distanceNotEqual", attribute, [[values, distance, meters]]).to_s end |
.ends_with(attribute, value) ⇒ Object
71 72 73 |
# File 'lib/appwrite/query.rb', line 71 def ends_with(attribute, value) return Query.new("endsWith", attribute, value).to_s end |
.equal(attribute, value) ⇒ Object
31 32 33 |
# File 'lib/appwrite/query.rb', line 31 def equal(attribute, value) return Query.new("equal", attribute, value).to_s end |
.greater_than(attribute, value) ⇒ Object
47 48 49 |
# File 'lib/appwrite/query.rb', line 47 def greater_than(attribute, value) return Query.new("greaterThan", attribute, value).to_s end |
.greater_than_equal(attribute, value) ⇒ Object
51 52 53 |
# File 'lib/appwrite/query.rb', line 51 def greater_than_equal(attribute, value) return Query.new("greaterThanEqual", attribute, value).to_s end |
.intersects(attribute, values) ⇒ Object
183 184 185 |
# File 'lib/appwrite/query.rb', line 183 def intersects(attribute, values) return Query.new("intersects", attribute, [values]).to_s end |
.is_not_null(attribute) ⇒ Object
59 60 61 |
# File 'lib/appwrite/query.rb', line 59 def is_not_null(attribute) return Query.new("isNotNull", attribute, nil).to_s end |
.is_null(attribute) ⇒ Object
55 56 57 |
# File 'lib/appwrite/query.rb', line 55 def is_null(attribute) return Query.new("isNull", attribute, nil).to_s end |
.less_than(attribute, value) ⇒ Object
39 40 41 |
# File 'lib/appwrite/query.rb', line 39 def less_than(attribute, value) return Query.new("lessThan", attribute, value).to_s end |
.less_than_equal(attribute, value) ⇒ Object
43 44 45 |
# File 'lib/appwrite/query.rb', line 43 def less_than_equal(attribute, value) return Query.new("lessThanEqual", attribute, value).to_s end |
.limit(limit) ⇒ Object
103 104 105 |
# File 'lib/appwrite/query.rb', line 103 def limit(limit) return Query.new("limit", nil, limit).to_s end |
.not_between(attribute, start, ending) ⇒ Object
123 124 125 |
# File 'lib/appwrite/query.rb', line 123 def not_between(attribute, start, ending) return Query.new("notBetween", attribute, [start, ending]).to_s end |
.not_contains(attribute, value) ⇒ Object
115 116 117 |
# File 'lib/appwrite/query.rb', line 115 def not_contains(attribute, value) return Query.new("notContains", attribute, value).to_s end |
.not_crosses(attribute, values) ⇒ Object
195 196 197 |
# File 'lib/appwrite/query.rb', line 195 def not_crosses(attribute, values) return Query.new("notCrosses", attribute, [values]).to_s end |
.not_ends_with(attribute, value) ⇒ Object
131 132 133 |
# File 'lib/appwrite/query.rb', line 131 def not_ends_with(attribute, value) return Query.new("notEndsWith", attribute, value).to_s end |
.not_equal(attribute, value) ⇒ Object
35 36 37 |
# File 'lib/appwrite/query.rb', line 35 def not_equal(attribute, value) return Query.new("notEqual", attribute, value).to_s end |
.not_intersects(attribute, values) ⇒ Object
187 188 189 |
# File 'lib/appwrite/query.rb', line 187 def not_intersects(attribute, values) return Query.new("notIntersects", attribute, [values]).to_s end |
.not_overlaps(attribute, values) ⇒ Object
203 204 205 |
# File 'lib/appwrite/query.rb', line 203 def not_overlaps(attribute, values) return Query.new("notOverlaps", attribute, [values]).to_s end |
.not_search(attribute, value) ⇒ Object
119 120 121 |
# File 'lib/appwrite/query.rb', line 119 def not_search(attribute, value) return Query.new("notSearch", attribute, value).to_s end |
.not_starts_with(attribute, value) ⇒ Object
127 128 129 |
# File 'lib/appwrite/query.rb', line 127 def not_starts_with(attribute, value) return Query.new("notStartsWith", attribute, value).to_s end |
.not_touches(attribute, values) ⇒ Object
211 212 213 |
# File 'lib/appwrite/query.rb', line 211 def not_touches(attribute, values) return Query.new("notTouches", attribute, [values]).to_s end |
.offset(offset) ⇒ Object
107 108 109 |
# File 'lib/appwrite/query.rb', line 107 def offset(offset) return Query.new("offset", nil, offset).to_s end |
.or(queries) ⇒ Object
159 160 161 |
# File 'lib/appwrite/query.rb', line 159 def or(queries) return Query.new("or", nil, queries.map { |query| JSON.parse(query) }).to_s end |
.order_asc(attribute) ⇒ Object
83 84 85 |
# File 'lib/appwrite/query.rb', line 83 def order_asc(attribute) return Query.new("orderAsc", attribute, nil).to_s end |
.order_desc(attribute) ⇒ Object
87 88 89 |
# File 'lib/appwrite/query.rb', line 87 def order_desc(attribute) return Query.new("orderDesc", attribute, nil).to_s end |
.order_random ⇒ Object
91 92 93 |
# File 'lib/appwrite/query.rb', line 91 def order_random() return Query.new("orderRandom", nil, nil).to_s end |
.overlaps(attribute, values) ⇒ Object
199 200 201 |
# File 'lib/appwrite/query.rb', line 199 def overlaps(attribute, values) return Query.new("overlaps", attribute, [values]).to_s end |
.search(attribute, value) ⇒ Object
79 80 81 |
# File 'lib/appwrite/query.rb', line 79 def search(attribute, value) return Query.new("search", attribute, value).to_s end |
.select(attributes) ⇒ Object
75 76 77 |
# File 'lib/appwrite/query.rb', line 75 def select(attributes) return Query.new("select", nil, attributes).to_s end |
.starts_with(attribute, value) ⇒ Object
67 68 69 |
# File 'lib/appwrite/query.rb', line 67 def starts_with(attribute, value) return Query.new("startsWith", attribute, value).to_s end |
.touches(attribute, values) ⇒ Object
207 208 209 |
# File 'lib/appwrite/query.rb', line 207 def touches(attribute, values) return Query.new("touches", attribute, [values]).to_s end |
.updated_after(value) ⇒ Object
151 152 153 |
# File 'lib/appwrite/query.rb', line 151 def updated_after(value) return greater_than("$updatedAt", value) end |
.updated_before(value) ⇒ Object
147 148 149 |
# File 'lib/appwrite/query.rb', line 147 def updated_before(value) return less_than("$updatedAt", value) end |
.updated_between(start, ending) ⇒ Object
155 156 157 |
# File 'lib/appwrite/query.rb', line 155 def updated_between(start, ending) return between("$updatedAt", start, ending) end |
Instance Method Details
#to_json(*args) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/appwrite/query.rb', line 18 def to_json(*args) { method: @method, attribute: @attribute, values: @values }.compact.to_json(*args) end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/appwrite/query.rb', line 26 def to_s return self.to_json end |