Project

partial_ks

0.0
No commit activity in last 3 years
No release in over 3 years
A library to sync a subset of your database
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 4.2.0
 Project Readme

PartialKs

A library to sync a subset of your database

Usage

See the following example:

configuration = [
  [User, nil, -> { User.where(:id => [1]) }],     # specify a subset of users. as users have no "parent", specify `nil`
  [BlogPost, User]                                # filter blog_posts by User
]

PartialKs::Sync.new(configuration).run! do |tables_to_filter, tables|
  puts tables_to_filter.inspect
  puts tables.inspect
end

So how does it work ?

The idea is that PartialKS builds a tree of models and uses the parent of a model to sync a subset of the database records for the model. E.g.

  User id 1, 3, 5, 7
  User -> BlogPost

PartialKS will only download blog_posts records for users 1, 3, 5, and 7.

Most of the time PartialKS will be able to deduce the parent automatically.

If a model has no "parent", PartialKS will download the whole table.

If a model has "multiple parents", then PartialKS will not choose, and hence will download the whole table. If it is not a problem to download the whole table, then you can address the warning at your leisure.

Public API

It currently consists of :

  • PartialKs::Sync

Not supported

Things that are not supported in this version.

  • Polymorphic relationships
  • Tables with STI