moor 1.1.1

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

moor #

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 for details.

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.1.1

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:moor/moor.dart';
  
Version Uploaded Documentation 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]
23
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]
62
Learn more about scoring.

We analyzed this package on Mar 10, 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:moor/moor.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.2-dev.0.0 <3.0.0
meta >=1.0.0 <2.0.0 1.1.7
Dev dependencies
build_runner ^1.2.0
build_test ^0.10.6
mockito ^4.0.0
moor_generator ^1.1.1
test ^1.5.3
test_api any