Module: Cequel::Record::Associations
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cequel/record/associations.rb
Overview
Cequel records can have parent-child relationships defined by belongs_to and has_many associations. Unlike in a relational database ORM, associations are not represented by foreign keys; instead they use CQL3’s compound primary keys. A child object’s primary key begins with it’s parent’s primary key.
In the below example, the ‘blogs` table has a one-column primary key `(subdomain)`, and the `posts` table has a two-column primary key `(blog_subdomain, permalink)`. All posts that belong to the blog with subdomain `“cassandra”` will have `“cassandra”` as their `blog_subdomain`.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/cequel/record/associations.rb', line 178 def destroy(*) super.tap do self.class.child_associations.each_value do |association| case association.dependent when :destroy __send__(association.name).destroy_all when :delete __send__(association.name).delete_all end end end end |