moor 1.4.0+2

moor #

Moor is an easy to use, reactive persistence library for Flutter apps. Define your database tables in pure Dart and enjoy a fluent query API, auto-updating streams and more!

This library defines the APIs for the moor persistence library. When using the library, you'll probably want to use the moor_flutter implementation directly.

Please see the homepage of moor or the moor_flutter package for details on how to use this package.

1.4.0+2 #

Fixes minor but annoying crashes.

1.4.0 #

  • Added the RealColumn, which stores floating point values
  • Better configuration for the serializer with the JsonKey annotation and the ability to use a custom ValueSerializer

1.3.0 #

  • Moor now supports table joins
    • Added table aliases
  • Default values for columns: Just use the withDefault method when declaring a column
    • added expressions that resolve to the current date or time
  • Fixed a crash that would occur if the first operation was a transaction
  • Better support for custom expressions as part of a regular query
  • Faster hashcode implementation in generated data classes

1.2.0 #

  • Breaking: Generated DAO classes are now called _$YourNameHere, it used to be just _YourNameHere (without the dollar sign)
  • Blob data type
  • insertOrReplace method for insert statements
  • DAOs can now operate on transactions
  • Custom constraints
  • Query streams are now cached so that equal queries yield identical streams. This can improve performance.

1.1.0 #

  • Transactions

1.0.0 #

  • Initial version of the Moor library

example/example.dart

import 'package:moor/moor.dart';

part 'example.g.dart';

// Define tables that can model a database of recipes.

@DataClassName('Category')
class Categories extends Table {
  IntColumn get id => integer().autoIncrement()();
  TextColumn get description => text().nullable()();
}

class Recipes extends Table {
  IntColumn get id => integer().autoIncrement()();
  TextColumn get title => text().withLength(max: 16)();
  TextColumn get instructions => text()();
  IntColumn get category => integer().nullable()();
}

class Ingredients extends Table {
  IntColumn get id => integer().autoIncrement()();
  TextColumn get name => text()();
  IntColumn get caloriesPer100g => integer().named('calories')();
}

class IngredientInRecipes extends Table {
  @override
  String get tableName => 'recipe_ingredients';

  // We can also specify custom primary keys
  @override
  Set<Column> get primaryKey => {recipe, ingredient};

  IntColumn get recipe => integer()();
  IntColumn get ingredient => integer()();

  IntColumn get amountInGrams => integer().named('amount')();
}

@UseMoor(tables: [Categories, Recipes, Ingredients, IngredientInRecipes])
class Database extends _$Database {
  Database(QueryExecutor e) : super(e);

  @override
  int get schemaVersion => 1;

  @override
  MigrationStrategy get migration => MigrationStrategy(onFinished: () async {
        // populate data
        await into(categories).insert(Category(description: 'Sweets'));
      });
}

Use this package as a library

1. Depend on it

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


dependencies:
  moor: ^1.4.0+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:moor/moor.dart';
  
Version Uploaded Documentation Archive
1.4.0+2 Jun 27, 2019 Go to the documentation of moor 1.4.0+2 Download moor 1.4.0+2 archive
1.4.0+1 Jun 11, 2019 Go to the documentation of moor 1.4.0+1 Download moor 1.4.0+1 archive
1.4.0 Jun 10, 2019 Go to the documentation of moor 1.4.0 Download moor 1.4.0 archive
1.3.2 May 9, 2019 Go to the documentation of moor 1.3.2 Download moor 1.3.2 archive
1.3.1 Apr 29, 2019 Go to the documentation of moor 1.3.1 Download moor 1.3.1 archive
1.3.0 Apr 20, 2019 Go to the documentation of moor 1.3.0 Download moor 1.3.0 archive
1.2.0 Mar 27, 2019 Go to the documentation of moor 1.2.0 Download moor 1.2.0 archive
1.1.1 Mar 10, 2019 Go to the documentation of moor 1.1.1 Download moor 1.1.1 archive
1.1.0 Mar 10, 2019 Go to the documentation of moor 1.1.0 Download moor 1.1.0 archive
1.0.0 Mar 9, 2019 Go to the documentation of moor 1.0.0 Download moor 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
49
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]
75
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
collection >=1.0.0 <2.0.0 1.14.11
meta >=1.0.0 <2.0.0 1.1.7
Dev dependencies
build_runner >=1.3.0 <2.0.0
build_test ^0.10.8
coverage ^0.12.4
grinder ^0.8.3
mockito ^4.1.0
moor_generator ^1.4.0
test ^1.6.4
test_api >=0.2.0 <1.0.0
test_core >=0.2.0 <1.0.0