Coder Social home page Coder Social logo

raku-modeldb's Introduction

NAME

ModelDB - an MVP ORM

SYNOPSIS

use DBIish;
use ModelDB;

module Model {
    use ModelDB::ModelBuilder;

    model Person {
        has Int $.person-id is column is primary;
        has Str $.name is column is rw
        has Int $.age is column is rw;
        has Str $.favorite-color is column is rw;
    }

    model Pet {
        has Str $.pet-id is column is primary;
        has Str $.name is column is rw;
        has Str $.animal is column is rw;
    }
}

class Schema is ModelDB::Schema {
    use ModelDB::SchemaBuilder;

    has ModelDB::Table[Person] $.persons is table;
    has ModelDB::Table[Pet] $.pets is table;
}

my $dbh = DBIish.connect('SQLite', :database<db.sqlite3>);
my $schema = Schema.new(:$dbh);

my $person = $schema.persons.create(%(
    name           => 'Steve',
    age            => 9,
    favorite-color => 'cyan',
));

$person.name           = 'Alex';
$person.age            = 4;
$person.favorite-color = 'green';

$schema.persons.update($person);

my $by-id = $schema.pets.find(pet-id(1));
my @cats = $schema.pets.search(:animal<cat>).all;

DESCRIPTION

This is a minimalist object relational mapping tool. It helps with mapping your database objects into Perl from an RDBMS. I am experimenting with this API to see what I can learn about RDBMS patterns, problems, and specific issues as related to Perl 6.

As such, this is highly experimental and I make no promises as regards the API. Though, I do use it in some production-ish code, so I don't want to change too much too fast.

My intent, though, is to use what I learn here to build a different library in a different namespace that does what I really want based on what I learn here.

My goals include:

over

Pod::Defn<140403348404624>

Pod::Defn<140403348404568>

Pod::Defn<140403332796200>

Pod::Defn<140403332796256>

Pod::Defn<140403332796312>

back

Performance and multiple RDBMS support are anti-goals. This will likely only support MySQL (and forks) and SQLite because that's what I care about. I do not plan to make performance improvements unless required and I especially do not intend to add any optimizations that harm code readability of even the internals unless required.

raku-modeldb's People

Contributors

zostay avatar

Watchers

 avatar James Cloos avatar  avatar

raku-modeldb's Issues

$.max-connector setting to ModelDB::Connector is probably useless

I don't have time to look into this right now, so I'm leaving a note for future me to look into the way resources are initialized in ModelDB::Connector.TWEAK. I suspect that I've erred in my understanding. I believe $!max-connections in there will have whatever value is set in the has definition when TWEAK is called, not the value given to BUILD. That resource allocation strategy is pretty lame anyway.

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.