got view queries happening correctly
This commit is contained in:
parent
32ffbfe019
commit
19a70ffd7d
7 changed files with 106 additions and 60 deletions
|
@ -37,17 +37,15 @@ module CouchRest
|
|||
# CouchDB's response.
|
||||
def save
|
||||
raise ArgumentError, "doc.database required for saving" unless database
|
||||
if new_record?
|
||||
create
|
||||
else
|
||||
update
|
||||
end
|
||||
result = database.save self
|
||||
result['ok']
|
||||
end
|
||||
|
||||
# Deletes the document from the database. Runs the :delete callbacks.
|
||||
# Removes the <tt>_id</tt> and <tt>_rev</tt> fields, preparing the
|
||||
# document to be saved to a new <tt>_id</tt>.
|
||||
def destroy
|
||||
raise ArgumentError, "doc.database required to destroy" unless database
|
||||
result = database.delete self
|
||||
if result['ok']
|
||||
self['_rev'] = nil
|
||||
|
@ -56,27 +54,6 @@ module CouchRest
|
|||
result['ok']
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Saves a document for the first time, after running the before(:create)
|
||||
# callbacks, and applying the unique_id.
|
||||
def create
|
||||
set_unique_id if respond_to?(:set_unique_id) # hack
|
||||
save_doc
|
||||
end
|
||||
|
||||
# Saves the document and runs the :update callbacks.
|
||||
def update
|
||||
save_doc
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def save_doc
|
||||
result = database.save self
|
||||
result['ok']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue