Giter Club home page Giter Club logo

dml's Introduction

Dml

TODO: Write a gem description

Installation

Add this line to your application's Gemfile:

gem 'dml'

And then execute:

$ bundle

Or install it yourself as:

$ gem install dml

Usage

TODO: Write usage instructions here

Contributing

  1. Fork it ( https://github.com/[my-github-username]/dml/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

dml's People

Contributors

ptico avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

rajcybage

dml's Issues

Persist processor

Extract all preparation logic to the dedicated object under Repository namespace

Unit of work

Idea

Create unit of work implementation with identity map and smart bulk insert sessions. It will allow us to write clean, idiomatic code and don't care about performance.

Dml.session do
  company = Company.new(name: 'Simpsons Corp')

  %w(Marge Homer Bart Lisa).each do |name|
    user = User.new(name: name, company: company)
    UsersRepository.insert(user)
  end

  CompaniesRepository.insert(company)
end # trigger insert/update

will generate

INSERT INTO companies (name) VALUES ('Simpsons Corp'); -- id = 42
INSERT INTO users (name, company_id) VALUES ('Marge', 42), ('Homer', 42) ...

And

Dml.session do
  UsersRepository.preload(user_ids) # Will retrieve all records immediately

  user_ids.each do |id|
    UsersRepository.fetch(id) # will fetch record from the Identity Map
  end

  locations.each do |location|
    location.user # if preloaded will fetch record from Identity Map
  end
end

Roadmap

Relation mapper

  • Basic n..1 and 1..1 associations (#3)
  • Basic relation object
  • Relations container
  • Relations DSL
  • Topological sorting for associations

Session

  • Identity map
  • Delayed persistance storage
  • Session object

Entity

  • Association attribute

Repository

  • Persist processor (preprocess data before saving) #6
  • Extract persistance provider (Postgres) #5
  • Integrate Identity Map
  • Implement #{insert/update}_immediate methods (directly call provider methods and update IM)
  • Implement #preload method

Things to decide

  • How to comfortably and efficiently preload entity 1..n associated entities
  • How to comfortably and efficiently preload collection associated entities (all and exact)
  • How to manage self-references

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.