Socket
Book a DemoInstallSign in
Socket

mongoid-list

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoid-list

0.6.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Mongoid List

Mongoid List uses a position column to maintain an ordered list, with optional scoping. It uses atomic updates to keep lists in either a Collection or Embedded in sync.

Installation

Add to your Gemfile:

gem 'mongoid-list'

Usage

Add a list:

class CrowTRobot
  include Mongoid::Document
  include Mongoid::List

  lists

end

Available methods:


# Update Position

doc1.position  # => 1
doc2.position  # => 2

doc1.position = 2
doc1.save

doc1.position  # => 2
doc2.position  # => 1


# Reorder a Full List
Klass.update_positions_in_list!(elements)

Pass in all elements in new ordering.  Accepts documents or ids.

# Scope Information
doc.list_scoped?  		# If scoping has been defined
doc.list_scope_field		# Which field to scope against
doc.list_scope_value		# Value of the scoping field
doc.list_scope_conditions	# Additional query conditions for scoped lists.

Scoping

To scope the list, pass :scope on lists definition:

class TomServo
  include Mongoid::Document
  include Mongoid::List

  lists scope: :satellite_of_love_id
  belongs_to :satellite_of_love

end

TO-DO

  • Helper methods to move individual documents within the list.
  • Customizable filed name.

FAQs

Package last updated on 02 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.