Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Views::design_document doc #96

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/couchbase-orm/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ def self.#{find_method}(#{attr})
", __FILE__, __LINE__ - 4
end

# Ensures that the Couchbase design document is up-to-date with the defined views.
#
# This method checks the current state of the design document in the Couchbase bucket
# and updates it if there are any discrepancies with the views defined in the current class.
#
# @return [Boolean] `true` if the design document was updated, `false` otherwise.
#
# @raise [Couchbase::Error::DesignDocumentNotFound] if the design document is not found.
#
# @example Ensure the design document is up-to-date
# class User
# include CouchbaseOrm::Model
#
# view :by_email, emit_key: :email
# view :by_username, emit_key: :username
# end
#
# # This will check the current design document for discrepancies and update if needed
# User.ensure_design_document!
def ensure_design_document!
return false unless @views && [email protected]?

Expand Down
Loading