Class: DatastaxRails::WideStorageModel
- Defined in:
- lib/datastax_rails/wide_storage_model.rb
Overview
A special model that is designed to efficiently store very wide data. This model type assumes that you have a unique ID that you want to store a lot of data about. The data is stored as a single, very wide row; however you can safely treat it as if there were multiple rows. A common example of this is a logs table
You can also apply secondary indexes onto the other columns.
CAVEATS:
-
Once the cluster attribute is set, it cannot be changed as it becomes the column header in Cassandra
class AuditLog < DatastaxRails::WideStorageModel
self.column_family = 'audit_logs' self.primary_key = :uuid self.cluster_by = :created_at # If you don't want the default ascending sort order self. = 'CLUSTERING ORDER BY (created_at DESC)' string :uuid string :message string :user_id, :cql_index => true
end
Direct Known Subclasses
Constant Summary
Constants included from Callbacks
Instance Attribute Summary
Attributes inherited from Base
#attributes, #key, #loaded_attributes
Attributes included from AutosaveAssociation
#destroyed_by_association, #marked_for_destruction
Attributes included from Associations
Instance Method Summary collapse
-
#id_for_update ⇒ Object
Returns a primary key hash for updates that includes the cluster key.
Methods inherited from Base
#==, attribute_names, #attribute_names, base_class, #column_names, columns, default_page_size, #eql?, find_by_id, #freeze, #frozen?, #hash, #init_changed_attributes, #init_internals, #init_with, #initialize, inspect, logger, models, payload_model?, search_ids, #to_param, #valid_consistency?, valid_consistency?, wide_storage_model?
Methods included from SolrRepair
Methods included from Serialization
#as_json, #serializable_hash, #to_xml
Methods included from Timestamps
Methods included from Scoping
#populate_with_current_scope_attributes
Methods included from AutosaveAssociation
#changed_for_autosave?, #mark_for_destruction, #reload
Methods included from Associations
#association, #clear_association_cache
Methods included from Callbacks
Methods included from Validations
Methods included from AttributeMethods
#attribute_exists?, #column_for_attribute, #method_missing, #respond_to?
Methods included from AttributeAssignment
Methods included from Batches
#find_each, #find_each_with_index, #find_in_batches
Methods included from FinderMethods
#find, #find_by, #find_by!, #first, #first!, #last, #last!
Methods included from Persistence
#destroy, #persisted?, #reload, #save, #save!, #toggle, #toggle!, #update_attribute, #update_attributes, #update_attributes!
Constructor Details
This class inherits a constructor from DatastaxRails::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DatastaxRails::AttributeMethods
Instance Method Details
#id_for_update ⇒ Object
Returns a primary key hash for updates that includes the cluster key
29 30 31 |
# File 'lib/datastax_rails/wide_storage_model.rb', line 29 def id_for_update { self.class.primary_key.to_s => id, self.class.cluster_by.to_s => read_attribute(self.class.cluster_by.to_s) } end |