Coder Social home page Coder Social logo

parentry's Introduction

Build Status Maintainability Test Coverage

Parentry

Parentry in its current incarnation is an ActiveRecord extension for the PostgreSQL ltree module.

The API is inspired by the popular ancestry gem and mirrors (with a few exceptions) the methods available in that gem.

Installation

Add this line to your application's Gemfile:

gem 'parentry'

And then execute:

$ bundle

Or install it yourself as:

$ gem install parentry

Usage

This gem requires 2 columns for each table: parentry and parent_id, and can leverage either the ltree postgresql extension, or else postgres array columns. A sample migration would look like:

enable_extension 'ltree' # ltree is not turned on by default; skip if you use the array strategy

add_column :my_table, :parent_id, :integer

add_column :my_table, :parentry, :ltree
add_column :my_table, :parentry_depth, :integer, default: 0 # optional

add_index :my_table, :parentry, using: :gist
class MyTable < ApplicationRecord
  include Parentry
  parentry cache_depth: true
  # to change strategy to array, and avoid dependency on ltree
  # parentry strategy: :array
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hasghari/parentry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

parentry's People

Contributors

hasghari avatar wheeyls avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.