module Qujo module Database module Mongoid extend ActiveSupport::Concern included do raise Qujo::Exceptions::DatabaseUndefined, "Mongoid is undefined" unless defined?(Mongoid) include ::Mongoid::Document include ::Mongoid::Timestamps include ::Mongoid::Symbolize field :data, type: Hash symbolize :status, in: [:new, :working, :waiting, :complete, :error, :retry, :cancelled], default: "new" field :message, type: String field :log, type: Array, default: [] field :trace, type: Array, default: [] field :accepted_at, type: DateTime default_scope where(accepted_at: nil) scope :active, -> { where(:status.in => [:new, :working, :waiting, :retry, :error], accepted_at: nil) } scope :errors, -> { where(:status.in => [:error]) } end end end end