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
- .cursor_after(id) ⇒ Object
- .cursor_before(id) ⇒ Object
- .ends_with(attribute, value) ⇒ Object
- .equal(attribute, value) ⇒ Object
- .greater_than(attribute, value) ⇒ Object
- .greater_than_equal(attribute, value) ⇒ 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_equal(attribute, value) ⇒ Object
- .offset(offset) ⇒ Object
- .or(queries) ⇒ Object
- .order_asc(attribute) ⇒ Object
- .order_desc(attribute) ⇒ Object
- .search(attribute, value) ⇒ Object
- .select(attributes) ⇒ Object
- .starts_with(attribute, value) ⇒ 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
115 116 117 |
# File 'lib/appwrite/query.rb', line 115 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
107 108 109 |
# File 'lib/appwrite/query.rb', line 107 def contains(attribute, value) return Query.new("contains", attribute, value).to_s end |
.cursor_after(id) ⇒ Object
95 96 97 |
# File 'lib/appwrite/query.rb', line 95 def cursor_after(id) return Query.new("cursorAfter", nil, id).to_s end |
.cursor_before(id) ⇒ Object
91 92 93 |
# File 'lib/appwrite/query.rb', line 91 def cursor_before(id) return Query.new("cursorBefore", nil, id).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 |
.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
99 100 101 |
# File 'lib/appwrite/query.rb', line 99 def limit(limit) return Query.new("limit", nil, limit).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 |
.offset(offset) ⇒ Object
103 104 105 |
# File 'lib/appwrite/query.rb', line 103 def offset(offset) return Query.new("offset", nil, offset).to_s end |
.or(queries) ⇒ Object
111 112 113 |
# File 'lib/appwrite/query.rb', line 111 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 |
.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 |
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 |