Sha256: e3871b9eda67efaa946144952b5d1daf8c89c12c39c0a2f7ea573001263dba6c

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

class Band
  include Mongoid::Document
  include Mongoid::Attributes::Dynamic

  field :name, type: String
  field :active, type: Mongoid::Boolean, default: true
  field :origin, type: String
  field :genres, type: Array
  field :member_count, type: Integer
  field :mems, as: :members, type: Array
  field :likes, type: Integer
  field :views, type: Integer
  field :rating, type: Float
  field :upserted, type: Mongoid::Boolean, default: false
  field :created, type: DateTime
  field :sales, type: BigDecimal
  field :decimal, type: BSON::Decimal128
  field :y, as: :years, type: Integer
  field :founded, type: Date
  field :deleted, type: Boolean

  embeds_many :records, cascade_callbacks: true
  embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
  embeds_many :labels
  embeds_one :label, cascade_callbacks: true

  scope :highly_rated, -> { gte(rating: 7) }

  has_many :artists
  has_many :same_name, class_name: 'Agent', inverse_of: :same_name

  after_upsert do |doc|
    doc.upserted = true
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-7.5.4 spec/support/models/band.rb
mongoid-7.5.3 spec/support/models/band.rb
mongoid-7.5.2 spec/support/models/band.rb
mongoid-7.5.1 spec/support/models/band.rb
mongoid-7.4.3 spec/support/models/band.rb
mongoid-7.5.0 spec/support/models/band.rb
mongoid-7.4.1 spec/support/models/band.rb
mongoid-7.4.0 spec/support/models/band.rb