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
-
.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
188 189 190 |
# File 'lib/appwrite/query.rb', line 188 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
136 137 138 |
# File 'lib/appwrite/query.rb', line 136 def contains(attribute, value) return Query.new("contains", attribute, value).to_s end |
.created_after(value) ⇒ Object
164 165 166 |
# File 'lib/appwrite/query.rb', line 164 def created_after(value) return greater_than("$createdAt", value) end |
.created_before(value) ⇒ Object
160 161 162 |
# File 'lib/appwrite/query.rb', line 160 def created_before(value) return less_than("$createdAt", value) end |
.created_between(start, ending) ⇒ Object
168 169 170 |
# File 'lib/appwrite/query.rb', line 168 def created_between(start, ending) return between("$createdAt", start, ending) end |
.crosses(attribute, values) ⇒ Object
225 226 227 |
# File 'lib/appwrite/query.rb', line 225 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
201 202 203 |
# File 'lib/appwrite/query.rb', line 201 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
209 210 211 |
# File 'lib/appwrite/query.rb', line 209 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
213 214 215 |
# File 'lib/appwrite/query.rb', line 213 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
205 206 207 |
# File 'lib/appwrite/query.rb', line 205 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.
197 198 199 |
# File 'lib/appwrite/query.rb', line 197 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
217 218 219 |
# File 'lib/appwrite/query.rb', line 217 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
148 149 150 |
# File 'lib/appwrite/query.rb', line 148 def not_between(attribute, start, ending) return Query.new("notBetween", attribute, [start, ending]).to_s end |
.not_contains(attribute, value) ⇒ Object
140 141 142 |
# File 'lib/appwrite/query.rb', line 140 def not_contains(attribute, value) return Query.new("notContains", attribute, value).to_s end |
.not_crosses(attribute, values) ⇒ Object
229 230 231 |
# File 'lib/appwrite/query.rb', line 229 def not_crosses(attribute, values) return Query.new("notCrosses", attribute, [values]).to_s end |
.not_ends_with(attribute, value) ⇒ Object
156 157 158 |
# File 'lib/appwrite/query.rb', line 156 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
221 222 223 |
# File 'lib/appwrite/query.rb', line 221 def not_intersects(attribute, values) return Query.new("notIntersects", attribute, [values]).to_s end |
.not_overlaps(attribute, values) ⇒ Object
237 238 239 |
# File 'lib/appwrite/query.rb', line 237 def not_overlaps(attribute, values) return Query.new("notOverlaps", attribute, [values]).to_s end |
.not_search(attribute, value) ⇒ Object
144 145 146 |
# File 'lib/appwrite/query.rb', line 144 def not_search(attribute, value) return Query.new("notSearch", attribute, value).to_s end |
.not_starts_with(attribute, value) ⇒ Object
152 153 154 |
# File 'lib/appwrite/query.rb', line 152 def not_starts_with(attribute, value) return Query.new("notStartsWith", attribute, value).to_s end |
.not_touches(attribute, values) ⇒ Object
245 246 247 |
# File 'lib/appwrite/query.rb', line 245 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
184 185 186 |
# File 'lib/appwrite/query.rb', line 184 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
233 234 235 |
# File 'lib/appwrite/query.rb', line 233 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
241 242 243 |
# File 'lib/appwrite/query.rb', line 241 def touches(attribute, values) return Query.new("touches", attribute, [values]).to_s end |
.updated_after(value) ⇒ Object
176 177 178 |
# File 'lib/appwrite/query.rb', line 176 def updated_after(value) return greater_than("$updatedAt", value) end |
.updated_before(value) ⇒ Object
172 173 174 |
# File 'lib/appwrite/query.rb', line 172 def updated_before(value) return less_than("$updatedAt", value) end |
.updated_between(start, ending) ⇒ Object
180 181 182 |
# File 'lib/appwrite/query.rb', line 180 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 |