flutter_orm_m8 0.3.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new76

Flutter ORM Mate - flutter_orm_m8 #

GitHub release pub package Build Status

Flutter package for ORM annotations.

Introduction #

The package adds definitions for a set of types that could be combined to expand ORM capabilities in the annotated code. The current version, defines three annotation types:

  • ColumnMetadata
  • DataTable
  • DataColumn

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

  • DbEntity
  • DbAccountEntity
  • DbAccountRelatedEntity

ColumnMetadata #

The ColumnMetadata describes the basic options for a column definition:

  • Ignore
  • PrimaryKey
  • Unique
  • NotNull
  • AutoIncrement
  • Indexed

The options may be combined in various ways using | operator

@DataColumn("id", ColumnMetadata.PrimaryKey | ColumnMetadata.Unique | ColumnMetadata.AutoIncrement)

DataTable #

DataTable describes the required name for the table

@DataTable("a01_tests")
class A01Test implements DbAccountRelatedEntity {

DataColumn #

DataColumn describes the required name for the column in conjunction with a bit mask for required ColumnMetadata's

  @DataColumn("id", ColumnMetadata.PrimaryKey | ColumnMetadata.Unique | ColumnMetadata.AutoIncrement)
  int _id;

Usage #

The package can be a start for other projects that aim to develop an ORM. Such project is https://github.com/matei-tm/flutter-sqlite-m8-generator

@DataTable("a01_tests")
class A01Test implements DbAccountRelatedEntity {
  @DataColumn("id", ColumnMetadata.PrimaryKey | ColumnMetadata.Unique | ColumnMetadata.AutoIncrement)
  int _id;

  @DataColumn("account_id")
  int _accountId;

  @DataColumn("record_date")
  int _recordDate;

  @DataColumn("is_deleted")
  int _isDeleted;

  A01Test.fromMap(Map<String, dynamic> map) {
    this._id = map['id'];
    this._accountId = map['account_id'];    
    this._recordDate = map['record_date'];
    this._isDeleted = map['is_deleted'];
  }

  @override
  A01Test getDbEntityFromMap(Map<String, dynamic> map) {
    return A01Test.fromMap(map);
  }  
}

[0.0.1] - 2018-03-01

  • Basic annotations for ORM extensions

ColumnMetadata options: #

  • Ignore
  • PrimaryKey
  • Unique
  • NotNull
  • AutoIncrement
  • Indexed

DataTable with name #

DataColumn with name and a bit mask for required ColumnMetadata's #

[0.0.2] - 2018-03-01

  • Adding some example usage

[0.0.3] - 2018-03-02

  • Shifting column options values with one bit
  • Enhancing documentation
  • Reorganizing example

[0.1.0] - 2018-03-03

  • Switching from flutter_test to test
  • Removing flutter dependencies

[0.2.0] - 2018-03-08

  • Adding base classes for:
    • DbEntity
    • DbAccountEntity
    • DbAccountRelatedEntity

[0.3.0] - 2018-03-15

  • Changing DbEntity:
    • Adding abstract method getDbEntityFromMap(Map<String, dynamic> map);

example/example.dart

import 'package:flutter_orm_m8/flutter_orm_m8.dart';

@DataTable("health_issues")
class HealthIssue implements DbAccountRelatedEntity {
  @DataColumn(
      "id",
      ColumnMetadata.PrimaryKey |
          ColumnMetadata.Unique |
          ColumnMetadata.AutoIncrement)
  int _id;

  @DataColumn("account_id")
  int _accountId;

  @DataColumn("record_date")
  int _recordDate;

  @DataColumn("is_deleted")
  int _isDeleted;

  @DataColumn("description")
  String _description;

  int get id => _id;
  int get accountId => _accountId;
  int get recordDate => _recordDate;
  int get isDeleted => _isDeleted;
  String get description => _description;

  HealthIssue(this._recordDate, this._accountId, this._description);
  HealthIssue.fromMap(Map<String, dynamic> map) {
    this._id = map['id'];
    this._accountId = map['account_id'];
    this._recordDate = map['record_date'];
    this._isDeleted = map['is_deleted'];

    this._description = map['description'];
  }
  @override
  Map<String, dynamic> toMap() {
    var map = Map<String, dynamic>();
    if (_id != null) {
      map['id'] = _id;
    }
    map['account_id'] = _accountId;
    map['record_date'] = _recordDate;
    map['is_deleted'] = _isDeleted;

    return map;
  }

  @override
  HealthIssue getDbEntityFromMap(Map<String, dynamic> map) {
    return HealthIssue.fromMap(map);
  }
  /* ... */
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_orm_m8: ^0.3.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_orm_m8/flutter_orm_m8.dart';
  
Version Uploaded Documentation Archive
0.3.0 Mar 15, 2019 Go to the documentation of flutter_orm_m8 0.3.0 Download flutter_orm_m8 0.3.0 archive
0.2.0 Mar 8, 2019 Go to the documentation of flutter_orm_m8 0.2.0 Download flutter_orm_m8 0.2.0 archive
0.1.0 Mar 4, 2019 Go to the documentation of flutter_orm_m8 0.1.0 Download flutter_orm_m8 0.1.0 archive
0.0.3 Mar 2, 2019 Go to the documentation of flutter_orm_m8 0.0.3 Download flutter_orm_m8 0.0.3 archive
0.0.2 Mar 1, 2019 Go to the documentation of flutter_orm_m8 0.0.2 Download flutter_orm_m8 0.0.2 archive
0.0.1 Mar 1, 2019 Go to the documentation of flutter_orm_m8 0.0.1 Download flutter_orm_m8 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

We analyzed this package on Mar 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:flutter_orm_m8/flutter_orm_m8.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
Dev dependencies
test ^1.3.3