Class: ZedDB::Models
- Inherits:
-
Object
- Object
- ZedDB::Models
- Defined in:
- lib/zeddb/resources/models.rb
Class Method Summary collapse
- .create(zks = {}, &block) ⇒ Object
- .delete(zks = {}, &block) ⇒ Object
-
.get(zks = {}, &block) ⇒ Object
ZedDB Database Models.
- .update(zks = {}, &block) ⇒ Object
Class Method Details
.create(zks = {}, &block) ⇒ Object
60 61 62 |
# File 'lib/zeddb/resources/models.rb', line 60 def create(zks = {}, &block) Zedkit::Client.crud(:create, 'db/models', zks, [], &block) end |
.delete(zks = {}, &block) ⇒ Object
68 69 70 |
# File 'lib/zeddb/resources/models.rb', line 68 def delete(zks = {}, &block) Zedkit::Client.crud(:delete, "db/models/#{zks[:uuid]}", zks, [], &block) end |
.get(zks = {}, &block) ⇒ Object
ZedDB Database Models
All ZedDB application databases have models. You can create, read, update, or delete models. To perform an operation on a specific model you need its UUID, as available from the Websites.models method.
To get a Model:
ZedDB::Models.get(:user_key => user['user_key'], :uuid => model['uuid'])
To update a Model:
ZedDB::Models.update(:user_key => user['user_key'], :uuid => model['uuid'])
To delete a Model:
ZedDB::Models.delete(:user_key => user['user_key'], :uuid => model['uuid'])
To create a new Model you submit the required parameters with the project UUID that you are creating the model for. Whatever items you send within the :model Hash are passed through to the ZedAPI untouched. There is no client side validation within this gem.
ZedDB::Models.create(:user_key => user['user_key'],
:project => { :uuid => project['uuid'] }, :model => { :name => 'whatever' })
From each of these requests the Zedkit::Client class will return a response hash for your reference, if needed, or as applicable to the request. If there was a HTTP 401 or 404 you will get a nil response. This indicates a security failure or that an UUID is incorrect, not attached the user’s account, or non-existent.
For each request you can also pass a block to process the response directly:
ZedDB::Models.get(:user_key => user['user_key'], :uuid => model['uuid']) do |result|
end
56 57 58 |
# File 'lib/zeddb/resources/models.rb', line 56 def get(zks = {}, &block) Zedkit::Client.crud(:get, "db/models/#{zks[:uuid]}", zks, [], &block) end |
.update(zks = {}, &block) ⇒ Object
64 65 66 |
# File 'lib/zeddb/resources/models.rb', line 64 def update(zks = {}, &block) Zedkit::Client.crud(:update, "db/models/#{zks[:uuid]}", zks, [], &block) end |