Dart pub

entify 0.2.3

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('/');
}