Class: Appwrite::Database
- Defined in:
- lib/appwrite/services/database.rb
Instance Method Summary collapse
- #create_collection(name:, read:, write:, rules:) ⇒ Object
- #create_document(collection_id:, data:, read:, write:, parent_document: '', parent_property: '', parent_property_type: 'assign') ⇒ Object
- #delete_collection(collection_id:) ⇒ Object
- #delete_document(collection_id:, document_id:) ⇒ Object
- #get_collection(collection_id:) ⇒ Object
- #get_collection_logs(collection_id:) ⇒ Object
- #get_document(collection_id:, document_id:) ⇒ Object
- #list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') ⇒ Object
- #list_documents(collection_id:, filters: [], offset: 0, limit: 50, order_field: '$id', order_type: 'ASC', order_cast: 'string', search: '', first: 0, last: 0) ⇒ Object
- #update_collection(collection_id:, name:, read:, write:, rules: []) ⇒ Object
- #update_document(collection_id:, document_id:, data:, read:, write:) ⇒ Object
Methods inherited from Service
Constructor Details
This class inherits a constructor from Appwrite::Service
Instance Method Details
#create_collection(name:, read:, write:, rules:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/appwrite/services/database.rb', line 19 def create_collection(name:, read:, write:, rules:) path = '/database/collections' params = { 'name': name, 'read': read, 'write': write, 'rules': rules } return @client.call('post', path, { 'content-type' => 'application/json', }, params); end |
#create_document(collection_id:, data:, read:, write:, parent_document: '', parent_property: '', parent_property_type: 'assign') ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/appwrite/services/database.rb', line 95 def create_document(collection_id:, data:, read:, write:, parent_document: '', parent_property: '', parent_property_type: 'assign') path = '/database/collections/{collectionId}/documents' .gsub('{collectionId}', collection_id) params = { 'data': data, 'read': read, 'write': write, 'parentDocument': parent_document, 'parentProperty': parent_property, 'parentPropertyType': parent_property_type } return @client.call('post', path, { 'content-type' => 'application/json', }, params); end |
#delete_collection(collection_id:) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/appwrite/services/database.rb', line 62 def delete_collection(collection_id:) path = '/database/collections/{collectionId}' .gsub('{collectionId}', collection_id) params = { } return @client.call('delete', path, { 'content-type' => 'application/json', }, params); end |
#delete_document(collection_id:, document_id:) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/appwrite/services/database.rb', line 142 def delete_document(collection_id:, document_id:) path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collectionId}', collection_id) .gsub('{documentId}', document_id) params = { } return @client.call('delete', path, { 'content-type' => 'application/json', }, params); end |
#get_collection(collection_id:) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/appwrite/services/database.rb', line 34 def get_collection(collection_id:) path = '/database/collections/{collectionId}' .gsub('{collectionId}', collection_id) params = { } return @client.call('get', path, { 'content-type' => 'application/json', }, params); end |
#get_collection_logs(collection_id:) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/appwrite/services/database.rb', line 155 def get_collection_logs(collection_id:) path = '/database/collections/{collectionId}/logs' .gsub('{collectionId}', collection_id) params = { } return @client.call('get', path, { 'content-type' => 'application/json', }, params); end |
#get_document(collection_id:, document_id:) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/appwrite/services/database.rb', line 113 def get_document(collection_id:, document_id:) path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collectionId}', collection_id) .gsub('{documentId}', document_id) params = { } return @client.call('get', path, { 'content-type' => 'application/json', }, params); end |
#list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/appwrite/services/database.rb', line 4 def list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') path = '/database/collections' params = { 'search': search, 'limit': limit, 'offset': offset, 'orderType': order_type } return @client.call('get', path, { 'content-type' => 'application/json', }, params); end |
#list_documents(collection_id:, filters: [], offset: 0, limit: 50, order_field: '$id', order_type: 'ASC', order_cast: 'string', search: '', first: 0, last: 0) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/appwrite/services/database.rb', line 74 def list_documents(collection_id:, filters: [], offset: 0, limit: 50, order_field: '$id', order_type: 'ASC', order_cast: 'string', search: '', first: 0, last: 0) path = '/database/collections/{collectionId}/documents' .gsub('{collectionId}', collection_id) params = { 'filters': filters, 'offset': offset, 'limit': limit, 'orderField': order_field, 'orderType': order_type, 'orderCast': order_cast, 'search': search, 'first': first, 'last': last } return @client.call('get', path, { 'content-type' => 'application/json', }, params); end |
#update_collection(collection_id:, name:, read:, write:, rules: []) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/appwrite/services/database.rb', line 46 def update_collection(collection_id:, name:, read:, write:, rules: []) path = '/database/collections/{collectionId}' .gsub('{collectionId}', collection_id) params = { 'name': name, 'read': read, 'write': write, 'rules': rules } return @client.call('put', path, { 'content-type' => 'application/json', }, params); end |
#update_document(collection_id:, document_id:, data:, read:, write:) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/appwrite/services/database.rb', line 126 def update_document(collection_id:, document_id:, data:, read:, write:) path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collectionId}', collection_id) .gsub('{documentId}', document_id) params = { 'data': data, 'read': read, 'write': write } return @client.call('patch', path, { 'content-type' => 'application/json', }, params); end |