Giter Club home page Giter Club logo

meadow's Introduction

Meadow is a first draft of a scala ORM. I am not convinced its possible to make
an ORM that is actively good, so where possible I have tried to cut features
out.

Meadow is definitely inspired by Lift's Record and Field, both as a pattern and
as an anti-pattern. It borrows from lift, hopefully without replicating its
flaws.

*ValueContainer*: One of the biggest frustrations with Lift's Field/Record
classes is the sheer number of classes involved in its inheritance hierarchy.
It is incredibly difficult to figure out what types are accepted by various
methods or returned by them, let alone what the implementations of those
methods are. To address that problem, Meadow only has one concrete
ValueContainer class, and any additions in functionality are added either
through a Serializer or a custom Extension.

*Serializers* are responsible for mapping between the BSONObject's
that mongo provides and the logical types we actually want to program against.
It's trivial to support a new logical type by adding a new Serializer, usually
with <10 lines of code.

*Extensions* allow the addition of type-safe functionality to a ValueContainer
through composition, not inheritance. For example, the FKExtension provided
here allows for some fields to be marked as a foreign key to another
collection, and to have logic for looking up the referenced object. Extension's
are also given a pointer to the associated ValueContainer at construction-time
and have a callback that's triggered when the value of a field changes, so they
have a great deal of flexibility.

*Schemas* allow the declaration of an individual collection as a group of
fields. This is very much inspired by the MetaRecord idea in Lift, but there is
no inheritance relationship between the singleton Schema and the individual
Record.

*Records* are created to model an individual record in a database. Each record
contains a set of ValueContainer's and has a reference back to the Schema with
which it's associated.


Note:

- It is annoying that every field must be declared in its Schema and in its
   Record. I don't know of a way to fix without adding an undesired inheritance
   relationship or code-gen. Given those two alternatives, I think the
   inconvenience of the extra line in each Record isn't too bad.
- It is difficult to have traits shared across multiple Records.
- There is no relationship between a ValueContainer and the field that owns it,
   so you can't do x.foo(1).bar(2) like you can in lift.
- There is no .toForm or .validate functionality. Display logic and model logic
   do not belong together so explicitly, but it would be possible to make an
   Extension to add that functionality if desired.
- Meadow is relatively strict about failures, so it throws an exception if it
   can't parse a value in the DB, for example.

meadow's People

Stargazers

Neil Sanchala avatar

Watchers

Neil Sanchala 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.