Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoid-tll

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoid-tll

  • 0.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Mongoid Top Linked List

A relatively simple module that provides a doubly top linked list for your documents. Every change creates a new document, with a link to the old one. All the documents have a link to the newest document. This setup should provide better performance in applications that usually need the newest version.

An example:

require 'mongoid'
require 'mongoid-tll'

class MyDocument
  include Mongoid::Document
  include Mongoid::TLL
  
  field :data
end

@doc = MyDocument.create(data: "first version")
@doc.data = "second version"
@doc.save

@doc.data
>> "second version"
@doc.prev.data
>> "first version"

A default scope is added to only find the newest versions by default. Use the scopeless method to circumvent this.

Other helper methods have been added:

  • newest - Returns the newest version of the document.
  • newest? - Is this the newest version?
  • oldest? - Is this the oldest (original) version?
  • prev - Returns the previous version of the document.

FAQs

Package last updated on 13 Apr 2011

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc