flood 0.1.4

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

Flood #

A data-generator for databases using Aqueduct.

Usage #

An example for a Hero model containing a name field. This function could then be called in for example, any Harness with the TestHarnessORMMixin.

import 'package:aqueduct_test/aqueduct_test.dart';
import 'package:faker/faker.dart';
import 'package:flood/flood.dart';

class ExampleHarness extends TestHarness<DbChannel> with TestHarnessORMMixin {
  @override
  ManagedContext get context => channel.context;

  @override
  Future seed() async {
    await initializeDb(context);
  }

  initializeDb(ManagedContext context) async {
    // An instance of GenerationScheme needs to be created for each model
    var heroScheme = GenerationScheme(
      // The ManagedEntity instance for the Hero model
      context.entityForType(Hero),
      
      // The generation method to use for the name field
      {"name": () => "hero_" + faker.internet.userName()},
      
      // Number of objects to create
      5,
    );
    var flood = Flood(context);
    // Register the GenerationScheme.
    flood.register(heroScheme);
    return await flood.fill();
  }
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.1.4 #

  • Cleaned up the example
  • Moved faker to the dev_dependencies

0.1.3 #

  • Fixed partial docs due to missing library exports.

0.1.2 #

  • Fixed structure to follow the pub recommendations.

0.1.1 #

  • Initial version.

example/main.dart

import 'dart:math';

import 'package:aqueduct_test/aqueduct_test.dart';
import 'package:faker/faker.dart';
import 'package:flood/flood.dart';

import 'lib/db.dart';

class ExampleHarness extends TestHarness<DbChannel> with TestHarnessORMMixin {
  @override
  ManagedContext get context => channel.context;

  @override
  Future seed() async {
    await initializeDb(context);
  }

  Future<Map<ManagedEntity, List<ManagedObject>>> initializeDb(
      ManagedContext context) async {
    Flood flood = Flood(context);
    Faker faker = Faker();
    GenerationScheme heroScheme = GenerationScheme(
      context.entityForType(Hero),
      {"name": () => "hero_" + faker.internet.userName()},
      5,
    );

    GenerationScheme villainScheme = GenerationScheme(
      context.entityForType(Villain),
      {"name": () => "villain_" + faker.internet.userName()},
      5,
    );

    GenerationScheme rivalryScheme = GenerationScheme(
      context.entityForType(Rivalry),
      {},
      10,
    );

    GenerationScheme battleScheme = GenerationScheme(
      context.entityForType(Battle),
      {"heroWon": Random().nextBool},
      20,
    );

    GenerationScheme fanScheme = GenerationScheme(
      context.entityForType(Fan),
      {"name": () => "fan_" + faker.internet.userName()},
      5,
    );

    flood.registerAll([
      heroScheme,
      villainScheme,
      rivalryScheme,
      battleScheme,
      fanScheme,
    ]);
    return flood.fill();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flood: ^0.1.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flood/flood.dart';
  
Version Uploaded Documentation Archive
0.1.4 Feb 7, 2019 Go to the documentation of flood 0.1.4 Download flood 0.1.4 archive
0.1.3 Feb 5, 2019 Go to the documentation of flood 0.1.3 Download flood 0.1.3 archive
0.1.2 Feb 5, 2019 Go to the documentation of flood 0.1.2 Download flood 0.1.2 archive
0.1.1 Feb 5, 2019 Go to the documentation of flood 0.1.1 Download flood 0.1.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Apr 19, 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: other

Primary library: package:flood/flood.dart with components: io, isolate, mirrors.

Health suggestions

Fix lib/flood.dart. (-0.50 points)

Analysis of lib/flood.dart reported 1 hint:

line 15 col 8: Unused import: 'src/test/model/model.dart'.

Fix lib/src/dependancy_graph.dart. (-0.50 points)

Analysis of lib/src/dependancy_graph.dart reported 1 hint:

line 7 col 75: Use ; instead of {} for empty constructor bodies.

Fix lib/src/flood.dart. (-0.50 points)

Analysis of lib/src/flood.dart reported 1 hint:

line 19 col 38: Use ; instead of {} for empty constructor bodies.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
aqueduct ^3.1.0+1 3.2.1
Transitive dependencies
analyzer 0.35.4 0.36.0
args 1.5.1
async 2.2.0
charcode 1.1.2
codable 1.0.0
collection 1.14.11
convert 2.1.1
crypto 2.0.6
front_end 0.1.14 0.1.15
glob 1.1.7
isolate_executor 2.0.2+2
kernel 0.3.14 0.3.15
logging 0.11.3+2
meta 1.1.7
open_api 2.0.1
package_config 1.0.5
password_hash 2.0.0
path 1.6.2
postgres 1.0.2
pub_cache 0.2.3
pub_semver 1.4.2
safe_config 2.0.2
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+10
yaml 2.1.15
Dev dependencies
aqueduct_test ^1.0.0
faker ^1.0.0
pedantic ^1.4.0
test ^1.0.0