Dart Framework ORM M8

Mircea MATEI
Jun 15, 2019 · 3 min read
Image for post
Image for post

Another ORM? Why?

Targeted audience

Introduction

  • DataTable
  • DataColumn

In order to ease the code emitting, four abstract classes are defined:

  • DbOpenEntity: non constrained entity
  • DbEntity: an entity with Id as primary key
  • DbAccountEntity: a user account template with Id as primary key
  • DbAccountRelatedEntity: user related data entities

DataTable

TableMetadata

  • softDeletable
  • trackCreate
  • trackUpdate

The options may be combined in various ways using | operator

DataColumn

  • name
    - purpose: to specify the entity name
    - type: String
    - positional
    - mandatory
  • metadataLevel
    - purpose: syntactic sugar to specify common use cases
    - type: int as combination of ColumnMetadata
    - named
    - optional
  • compositeConstraints
    - purpose: a fine grain mode to specify composite constraints
    - type: List<CompositeConstraint>
    - named
    - optional

ColumnMetadata

  • ignore
  • primaryKey
  • unique
  • notNull
  • autoIncrement
  • indexed

The options can be combined in various ways using | operator

The primaryKey, unique, indexed constraints can be generated in a targetted way using CompositeConstraint

CompositeConstraint

  • name — the name of the constraint
  • constraintType — the type of the constraint as enum with the following values:
    - unique,
    - primaryKey,
    - foreignKey,
    - indexed

A simple approach

A fine tuned approach

Interfaces

DbOpenEntity

DbEntity

DbAccountEntity

  • userName
  • email
  • abbreviation
  • isCurrent

DbAccountRelatedEntity implements DbEntity

  • accountId

Usage convention

All set? Let’s go

References

If you have any questions or you would like to give me feedback, you’re invited to leave them below, on Gitter or Twitter.

May the f-orm-m8 be with you!

The Startup

Medium's largest active publication, followed by +734K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store