From eb1c5f7df228ec79f3f33de8124b30e782acb38f Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 30 Dec 2018 19:30:23 -0500 Subject: [PATCH] 1.0.1 --- CHANGELOG.md | 3 +++ README.md | 6 +----- example/main.dart | 20 ++++++++++++++++++++ lib/angel_model.dart | 10 +++++++++- pubspec.yaml | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 example/main.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index d710edf3..ad7c5bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,5 @@ +# 1.0.1 +* Add `idAsInt`. + # 1.0.0+1 * Update constraint to work with Dart 2. diff --git a/README.md b/README.md index 80a2b5c8..fdb704c9 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,7 @@ Angel's basic data model class, no longer with the added weight of the whole framework. ```dart -// Old: import 'package:angel_framework/common.dart' show Model; - -// The new way!!! import 'package:angel_model/angel_model.dart'; ``` -This package was created to prevent dependency collisions with third-party packages. -`framework/common` will continue to export this class. \ No newline at end of file +This package was created to prevent dependency collisions with third-party packages. \ No newline at end of file diff --git a/example/main.dart b/example/main.dart new file mode 100644 index 00000000..f6c5caef --- /dev/null +++ b/example/main.dart @@ -0,0 +1,20 @@ +import 'package:angel_model/angel_model.dart'; + +void main() { + var todo = Todo(id: '34', isComplete: false); + print(todo.idAsInt == 34); +} + +class Todo extends Model { + String text; + + bool isComplete; + + Todo( + {String id, + this.text, + this.isComplete, + DateTime createdAt, + DateTime updatedAt}) + : super(id: id, createdAt: createdAt, updatedAt: updatedAt); +} diff --git a/lib/angel_model.dart b/lib/angel_model.dart index c07e0596..c3290602 100644 --- a/lib/angel_model.dart +++ b/lib/angel_model.dart @@ -1,8 +1,16 @@ /// Represents arbitrary data, with an associated ID and timestamps. class Model { + /// A unique identifier corresponding to this item. String id; + + /// The time at which this item was created. DateTime createdAt; + + /// The last time at which this item was updated. DateTime updatedAt; Model({this.id, this.createdAt, this.updatedAt}); -} \ No newline at end of file + + /// Returns the [id], parsed as an [int]. + int get idAsInt => int.parse(id); +} diff --git a/pubspec.yaml b/pubspec.yaml index 20539a24..bfa889ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_model -version: 1.0.0+1 +version: 1.0.1 description: Angel's basic data model class, no longer with the added weight of the whole framework. author: Tobe O homepage: https://github.com/angel-dart/model