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
Filter resources where attribute contains the specified value.
-
.contains_all(attribute, value) ⇒ Object
Filter resources where attribute contains ALL of the specified values.
-
.contains_any(attribute, value) ⇒ Object
Filter resources where attribute contains ANY of the specified values.
- .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
-
.elem_match(attribute, queries) ⇒ String
Filter array elements where at least one element matches all the specified queries.
- .ends_with(attribute, value) ⇒ Object
- .equal(attribute, value) ⇒ Object
-
.exists(attributes) ⇒ String
Filter resources where the specified attributes exist.
- .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_exists(attributes) ⇒ String
Filter resources where the specified attributes do not exist.
- .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
-
.regex(attribute, pattern) ⇒ String
Filter resources where attribute matches a regular expression pattern.
- .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
206 207 208 |
# File 'lib/appwrite/query.rb', line 206 def and(queries) return Query.new("and", nil, queries.map { |query| JSON.parse(query) }).to_s end |
.between(attribute, start, ending) ⇒ Object
88 89 90 |
# File 'lib/appwrite/query.rb', line 88 def between(attribute, start, ending) return Query.new("between", attribute, [start, ending]).to_s end |
.contains(attribute, value) ⇒ Object
Filter resources where attribute contains the specified value. For string attributes, checks if the string contains the substring.
Note: For array attributes, use contains_any or contains_all instead.
140 141 142 |
# File 'lib/appwrite/query.rb', line 140 def contains(attribute, value) return Query.new("contains", attribute, value).to_s end |
.contains_all(attribute, value) ⇒ Object
Filter resources where attribute contains ALL of the specified values. For array and relationship attributes, matches documents where the attribute contains every one of the given values.
154 155 156 |
# File 'lib/appwrite/query.rb', line 154 def contains_all(attribute, value) return Query.new("containsAll", attribute, value).to_s end |
.contains_any(attribute, value) ⇒ Object
Filter resources where attribute contains ANY of the specified values. For array and relationship attributes, matches documents where the attribute contains at least one of the given values.
147 148 149 |
# File 'lib/appwrite/query.rb', line 147 def contains_any(attribute, value) return Query.new("containsAny", attribute, value).to_s end |
.created_after(value) ⇒ Object
182 183 184 |
# File 'lib/appwrite/query.rb', line 182 def created_after(value) return greater_than("$createdAt", value) end |
.created_before(value) ⇒ Object
178 179 180 |
# File 'lib/appwrite/query.rb', line 178 def created_before(value) return less_than("$createdAt", value) end |
.created_between(start, ending) ⇒ Object
186 187 188 |
# File 'lib/appwrite/query.rb', line 186 def created_between(start, ending) return between("$createdAt", start, ending) end |
.crosses(attribute, values) ⇒ Object
243 244 245 |
# File 'lib/appwrite/query.rb', line 243 def crosses(attribute, values) return Query.new("crosses", attribute, [values]).to_s end |
.cursor_after(id) ⇒ Object
124 125 126 |
# File 'lib/appwrite/query.rb', line 124 def cursor_after(id) return Query.new("cursorAfter", nil, id).to_s end |
.cursor_before(id) ⇒ Object
120 121 122 |
# File 'lib/appwrite/query.rb', line 120 def cursor_before(id) return Query.new("cursorBefore", nil, id).to_s end |
.distance_equal(attribute, values, distance, meters = true) ⇒ Object
219 220 221 |
# File 'lib/appwrite/query.rb', line 219 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
227 228 229 |
# File 'lib/appwrite/query.rb', line 227 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
231 232 233 |
# File 'lib/appwrite/query.rb', line 231 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
223 224 225 |
# File 'lib/appwrite/query.rb', line 223 def distance_not_equal(attribute, values, distance, meters = true) return Query.new("distanceNotEqual", attribute, [[values, distance, meters]]).to_s end |
.elem_match(attribute, queries) ⇒ String
Filter array elements where at least one element matches all the specified queries.
215 216 217 |
# File 'lib/appwrite/query.rb', line 215 def elem_match(attribute, queries) return Query.new("elemMatch", attribute, queries.map { |query| JSON.parse(query) }).to_s end |
.ends_with(attribute, value) ⇒ Object
96 97 98 |
# File 'lib/appwrite/query.rb', line 96 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 |
.exists(attributes) ⇒ String
Filter resources where the specified attributes exist.
76 77 78 |
# File 'lib/appwrite/query.rb', line 76 def exists(attributes) return Query.new("exists", nil, attributes).to_s end |
.greater_than(attribute, value) ⇒ Object
56 57 58 |
# File 'lib/appwrite/query.rb', line 56 def greater_than(attribute, value) return Query.new("greaterThan", attribute, value).to_s end |
.greater_than_equal(attribute, value) ⇒ Object
60 61 62 |
# File 'lib/appwrite/query.rb', line 60 def greater_than_equal(attribute, value) return Query.new("greaterThanEqual", attribute, value).to_s end |
.intersects(attribute, values) ⇒ Object
235 236 237 |
# File 'lib/appwrite/query.rb', line 235 def intersects(attribute, values) return Query.new("intersects", attribute, [values]).to_s end |
.is_not_null(attribute) ⇒ Object
68 69 70 |
# File 'lib/appwrite/query.rb', line 68 def is_not_null(attribute) return Query.new("isNotNull", attribute, nil).to_s end |
.is_null(attribute) ⇒ Object
64 65 66 |
# File 'lib/appwrite/query.rb', line 64 def is_null(attribute) return Query.new("isNull", attribute, nil).to_s end |
.less_than(attribute, value) ⇒ Object
48 49 50 |
# File 'lib/appwrite/query.rb', line 48 def less_than(attribute, value) return Query.new("lessThan", attribute, value).to_s end |
.less_than_equal(attribute, value) ⇒ Object
52 53 54 |
# File 'lib/appwrite/query.rb', line 52 def less_than_equal(attribute, value) return Query.new("lessThanEqual", attribute, value).to_s end |
.limit(limit) ⇒ Object
128 129 130 |
# File 'lib/appwrite/query.rb', line 128 def limit(limit) return Query.new("limit", nil, limit).to_s end |
.not_between(attribute, start, ending) ⇒ Object
166 167 168 |
# File 'lib/appwrite/query.rb', line 166 def not_between(attribute, start, ending) return Query.new("notBetween", attribute, [start, ending]).to_s end |
.not_contains(attribute, value) ⇒ Object
158 159 160 |
# File 'lib/appwrite/query.rb', line 158 def not_contains(attribute, value) return Query.new("notContains", attribute, value).to_s end |
.not_crosses(attribute, values) ⇒ Object
247 248 249 |
# File 'lib/appwrite/query.rb', line 247 def not_crosses(attribute, values) return Query.new("notCrosses", attribute, [values]).to_s end |
.not_ends_with(attribute, value) ⇒ Object
174 175 176 |
# File 'lib/appwrite/query.rb', line 174 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_exists(attributes) ⇒ String
Filter resources where the specified attributes do not exist.
84 85 86 |
# File 'lib/appwrite/query.rb', line 84 def not_exists(attributes) return Query.new("notExists", nil, attributes).to_s end |
.not_intersects(attribute, values) ⇒ Object
239 240 241 |
# File 'lib/appwrite/query.rb', line 239 def not_intersects(attribute, values) return Query.new("notIntersects", attribute, [values]).to_s end |
.not_overlaps(attribute, values) ⇒ Object
255 256 257 |
# File 'lib/appwrite/query.rb', line 255 def not_overlaps(attribute, values) return Query.new("notOverlaps", attribute, [values]).to_s end |
.not_search(attribute, value) ⇒ Object
162 163 164 |
# File 'lib/appwrite/query.rb', line 162 def not_search(attribute, value) return Query.new("notSearch", attribute, value).to_s end |
.not_starts_with(attribute, value) ⇒ Object
170 171 172 |
# File 'lib/appwrite/query.rb', line 170 def not_starts_with(attribute, value) return Query.new("notStartsWith", attribute, value).to_s end |
.not_touches(attribute, values) ⇒ Object
263 264 265 |
# File 'lib/appwrite/query.rb', line 263 def not_touches(attribute, values) return Query.new("notTouches", attribute, [values]).to_s end |
.offset(offset) ⇒ Object
132 133 134 |
# File 'lib/appwrite/query.rb', line 132 def offset(offset) return Query.new("offset", nil, offset).to_s end |
.or(queries) ⇒ Object
202 203 204 |
# File 'lib/appwrite/query.rb', line 202 def or(queries) return Query.new("or", nil, queries.map { |query| JSON.parse(query) }).to_s end |
.order_asc(attribute) ⇒ Object
108 109 110 |
# File 'lib/appwrite/query.rb', line 108 def order_asc(attribute) return Query.new("orderAsc", attribute, nil).to_s end |
.order_desc(attribute) ⇒ Object
112 113 114 |
# File 'lib/appwrite/query.rb', line 112 def order_desc(attribute) return Query.new("orderDesc", attribute, nil).to_s end |
.order_random ⇒ Object
116 117 118 |
# File 'lib/appwrite/query.rb', line 116 def order_random() return Query.new("orderRandom", nil, nil).to_s end |
.overlaps(attribute, values) ⇒ Object
251 252 253 |
# File 'lib/appwrite/query.rb', line 251 def overlaps(attribute, values) return Query.new("overlaps", attribute, [values]).to_s end |
.regex(attribute, pattern) ⇒ String
Filter resources where attribute matches a regular expression pattern.
44 45 46 |
# File 'lib/appwrite/query.rb', line 44 def regex(attribute, pattern) return Query.new("regex", attribute, pattern).to_s end |
.search(attribute, value) ⇒ Object
104 105 106 |
# File 'lib/appwrite/query.rb', line 104 def search(attribute, value) return Query.new("search", attribute, value).to_s end |
.select(attributes) ⇒ Object
100 101 102 |
# File 'lib/appwrite/query.rb', line 100 def select(attributes) return Query.new("select", nil, attributes).to_s end |
.starts_with(attribute, value) ⇒ Object
92 93 94 |
# File 'lib/appwrite/query.rb', line 92 def starts_with(attribute, value) return Query.new("startsWith", attribute, value).to_s end |
.touches(attribute, values) ⇒ Object
259 260 261 |
# File 'lib/appwrite/query.rb', line 259 def touches(attribute, values) return Query.new("touches", attribute, [values]).to_s end |
.updated_after(value) ⇒ Object
194 195 196 |
# File 'lib/appwrite/query.rb', line 194 def updated_after(value) return greater_than("$updatedAt", value) end |
.updated_before(value) ⇒ Object
190 191 192 |
# File 'lib/appwrite/query.rb', line 190 def updated_before(value) return less_than("$updatedAt", value) end |
.updated_between(start, ending) ⇒ Object
198 199 200 |
# File 'lib/appwrite/query.rb', line 198 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 |