README

NAME

Marrow - MRO, the opposite of ORM.

SYNOPSIS

bin/mro.raku [--app] [--mods] [--roles] [--templates] [--list] [--dbname=<Str>] [--host=<Str>] [--user=<Str>] [--password=<Str>] [--schema=<Str>] [--prefix=<Str>] [--help]

--app       : Generate the Cro main application and default routes.

--mods      : Generate the objects representing the DB tables.

--roles     : Generate the roles for the objects which define the basic methods of the objects.

--templates : Generate the index.html file for the Cro app which can be used for testing the APIs.

--list      : List the schemas available in the DB.

--prefix    : By default the Objects will name following this format {prefix}::{table}. By default prefix is the same as the schema name.

DESCRIPTION

Marrow (mro.raku) is an application that will, when pointed at a standards compliant SQL relational database (at the moment only Postgresql is supported) will interrogate the the given schema's tables (defaults to public) and their relationships. It will then generate a Cro application to serve APIs to manipulate those tables.

Note: At the moment mro requires all the tables to have a field called "id" as the primary key. It has been tested with "id" values of integer and uuid.

The code generated includes a set of object libraries and roles for those objects. The basic functionaliry for the objects are in the corresponding roles which the objects implement. User-written code should go into the object file itself. That way when the DB is altered the use may regenerate just the roles and templates to have them updated.

The new Cro application will be created in the results directory and will be set up in the following tree:

resources
    bin
        <dbname>.raku (Cro application)
    lib
        <prefix>
            roles
                <roles for object files (roles)>
            <object files (mods)>
        <user defined routes module>
    resouces
        templates
            html
                index.html

TO-DO

  • Move boilerplate to templating system (find a templating system).

  • Implement a security layer for the routes.

  • Move DB connection code to a single module in the generated app.

  • Generate a Dockerfile for generated app.

  • Let mro use ENV db connection information.

  • Set up real tests.

Dependencies

This app requires libpq and libuuid (ossp-uuid) be installed.

macOS: DB::Pg has trouble installing on MacOS. This is because the libpq on MacOS that is installed by Homebrew does not match the version defined by the module. This problem can be worked around by doing the following:

> git clone https://github.com/CurtTilmes/raku-dbpg.git
> cd raku-dbpg;
> sed -i '.bk' -e 's/\:ver\<5\>//g'  META6.json;
> zef install --exclude="pq" .

You may then install this application and things should work.

AUTHOR

Scott Sotka [email protected]

COPYRIGHT AND LICENSE

Copyright 2024 Scott Sotka

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

Marrow v0.0.2

Marrow (MRO) the reverse ORM. Generates code to create REST APIs for a Postgresql database.

Authors

  • zef:ssotka

License

Artistic-2.0

Dependencies

DB::Pg:ver<1.1>LibUUIDJSON::PrettyJSON::FastGetopt::LongCro::HTTP::RouterCro::HTTP::Server

Test Dependencies

Provides

  • API::Db
  • API::Db::App
  • API::Db::Mods
  • API::Db::Templates
  • mro

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.