entify 0.2.3

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 53

entify

A library to ease the use of the datastore with the googleapis package.

Features

Entity model mapping:

// ...

@entityModel
class Species {
  // This will handle the mapping between entify's Entity object and this model
  static final EntityBridge<Species> bridge = new EntityBridge<Species>();

  Species();

  // You can use a factory constructor for setting up an object from an entity.
  // This isn't really needed, I just like to create these shorthand cosntructors,
  // the bridge.fromEntity can be called anywhere.
  factory Species.fromEntity(Entity e) => bridge.fromEntity(e, new Species());

  // Or you can use a vanilla constructor if you prefer.
  Species.entity(Entity e) {
    bridge.fromEntity(e, this);
  }

  // Shorthand function for mapping this to an entify Entity object.
  Entity toEntity() => bridge.toEntity(this);

  @primaryKey
  String scientificName;
  @persistent
  String commonName;
  @persistent
  String status;

  // Fields can be renamed, marked as unindexed (not demonstrated here).
  @Persistent(name: "taxonomy")
  List<String> get taxonomyField => taxonomy.map((e) => e.toString()).toList();

  set taxonomyField(List<String> encodedTaxonomy) { /* ... */ }

  // This field is converted to/from a property via a getter/setter respectively.
  List<Taxon> taxonomy = [];

  // This is a lookup field generated from taxonomy, it doesn't need a setter.
  @persistent
  List<String> get taxonomyPaths { /* ... */ }

  // But currently EntityBridge requires a setter
  set taxonomyPaths(List<String> doesntMatter) {}

  // This is a non-persistent property.
  String get fullTaxonomyPath => taxonomy.join('/');
}

You can save some objects just by calling:

Future<Null> insertOrUpdateSpecies(DatastoreShell dsh, Iterable<Species> species) async {
  await (dsh.beginMutation()
      ..upsertAll(species.map((s) => s.toEntity())))
    .execute();
}

All the elements are optional, you can create googleapis level API objects and modify them if something is not supported.

Getting Started

Check out the https://github.com/skawa-universe/endangered_species/ project for an example and details on the class provided above.

0.2.3

  • Added containsProperty to Entity
  • The remove method on Entity returns the previously set value.
  • The read consistency can be specified with get calls
  • The default read consistency has been changed to null which means the service side default, which is different what it used to be with get calls and ancestor queries.

0.2.2

  • Entity: fixed propertyNames added toString
  • WrappedServerError will tell about the wrapped error in toString
  • Added a null check for the kind in the Key constructor
  • Incomplete Key values in entities are checked (they can still fail mutations if they are in a list)
  • Added EntityBridge methods that can be used as predicates: entityKindMatches and keyKindMatches

0.2.1+1

  • Fixed blob value handling

0.2.1

  • Added indexedIfNonNull.
  • Entity now supports accessing property names, so properties are now enumerable.
  • Empty commits are handled.
  • The setPropertiesFrom in the Entity class allows future proof entity updates.

0.2.0

  • Added support for transactions.
  • Renamed MutationBatch.execute and executeRaw to commit. The execute methods are deprecated now and will be removed in a future release.

0.1.2+2

  • Setters are optional for properties in entity model classes

0.1.2+1

  • Handles null values in fromValue better
  • Throws error if the entity model class does not have a key

0.1.2

  • Renamed fromProtocol to fromApiObject in Key and Entity to follow common naming convention
  • fromValue now handles empty values (treats them as null)
  • Entity throws more meaningful errors in fromApiObject

0.1.1+3

  • Added createKey method to EntityBridge
  • Created QueryResult interface

0.1.1

  • The bool parameter of toValue became a named parameter as it is recommended.

1. Depend on it

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


dependencies:
  entify: "^0.2.3"

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:entify/entify.dart';
        
Version Uploaded Documentation Archive
0.2.3 Feb 16, 2018 Go to the documentation of entify 0.2.3 Download entify 0.2.3 archive
0.2.2 Nov 23, 2017 Go to the documentation of entify 0.2.2 Download entify 0.2.2 archive
0.2.1+1 Oct 4, 2017 Go to the documentation of entify 0.2.1+1 Download entify 0.2.1+1 archive
0.2.1 Aug 22, 2017 Go to the documentation of entify 0.2.1 Download entify 0.2.1 archive
0.1.2+2 Jul 27, 2017 Go to the documentation of entify 0.1.2+2 Download entify 0.1.2+2 archive
0.1.2+1 Jul 7, 2017 Go to the documentation of entify 0.1.2+1 Download entify 0.1.2+1 archive
0.1.1+2 Jun 6, 2017 Go to the documentation of entify 0.1.1+2 Download entify 0.1.1+2 archive
0.1.1+1 Jun 6, 2017 Go to the documentation of entify 0.1.1+1 Download entify 0.1.1+1 archive
0.1.1 Jun 6, 2017 Go to the documentation of entify 0.1.1 Download entify 0.1.1 archive
0.1.0 Jun 6, 2017 Go to the documentation of entify 0.1.0 Download entify 0.1.0 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
13 / 100
Health:
Code health derived from static analysis. [more]
90 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
98 / 100
Overall score:
Weighted score of the above. [more]
53
Learn more about scoring.

Platforms

Detected platforms: web, other

Primary library: package:entify/entify.dart with components: mirrors.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 errors 14 hints.

    Strong-mode analysis of lib/src/datastore/options.dart failed with the following error:

    line: 15 col: 56
    The function expression type '(ReadConsistency) → String' isn't of type '(dynamic) → String'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).

    Strong-mode analysis of lib/src/datastore/query.dart failed with the following error:

    line: 113 col: 55
    The function expression type '(FilterOperator) → String' isn't of type '(dynamic) → String'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).

    Similar analysis of the following files failed:

    • lib/src/datastore/api_mapping.dart (hint)
    • lib/src/datastore/entity.dart (hint)
    • lib/src/datastore/errors.dart (hint)
    • lib/src/datastore/key.dart (hint)
    • lib/src/datastore/mutations.dart (hint)
    • lib/src/datastore/shell.dart (hint)
    • lib/src/datastore/util.dart (hint)
    • lib/src/datastore/values.dart (hint)
    • lib/src/entity/accessors.dart (hint)
    • lib/src/entity/errors.dart (hint)
    • lib/src/entity/metadata.dart (hint)
    • lib/src/entity/model.dart (hint)
  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use entify.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
googleapis >=0.39.0 <0.50.0 0.49.0 0.50.1
Transitive dependencies
_discoveryapis_commons 0.1.6
async 2.0.6
charcode 1.1.1
collection 1.14.9
http 0.11.3+16
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test