No release in over 3 years
Low commit activity in last 3 years
Extension to mongoid to define relationships which are fetched unscoped
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Unscoped Mongoid Relations gem

Install

gem 'mongoid-unscoped-relation'

Usage

In the case of the default query scope excluse some documents

class Document
  include Mongoid::Document
  include Mongoid::UnscopedBelongsTo

  unscoped_belongs_to :model

  field :deleted_at, type: DateTime
end

But in the relationship, it should find the given document by default

class Model
  include Mongoid::Document

  default_scope ->{ where(deleted_at: nil) }

  has_many :documents
end

So then when the model is used, it will always find all the document

> m = Model.create
> d = Document.create, model: m

> m.update deleted_at: Time.now
> Model.all.count
=> 0

> # Usually d.model => nil
> d.model
=> <Model _id: 123, deleted_at: [DateTime]>