Sha256: d02539dce71f628cfadccc3af6abb1392368299c83b0f9beec26a32e582fa036

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 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
  field :mojo, type: Object
  field :tags, type: Hash
  field :fans

  embeds_many :records, cascade_callbacks: true
  embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
  embeds_many :labels
  embeds_many :fanatics
  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

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-8.1.5 spec/support/models/band.rb
mongoid-8.1.4 spec/support/models/band.rb
mongoid-8.1.3 spec/support/models/band.rb
mongoid-8.1.2 spec/support/models/band.rb
mongoid-8.1.1 spec/support/models/band.rb
mongoid-8.1.0 spec/support/models/band.rb