Updated model

This commit is contained in:
thomashii 2021-08-08 10:45:56 +08:00
parent de18c82e66
commit 2643436d62
3 changed files with 4 additions and 5 deletions

View file

@ -3,7 +3,6 @@
## 3.0.2 ## 3.0.2
* Updated README * Updated README
* Updated `id` to be `required`
* Updated `idAsInt` to return `-1` instead of `null` for invalid id * Updated `idAsInt` to return `-1` instead of `null` for invalid id
## 3.0.1 ## 3.0.1

View file

@ -3,7 +3,7 @@
/// Represents arbitrary data, with an associated ID and timestamps. /// Represents arbitrary data, with an associated ID and timestamps.
class Model { class Model {
/// A unique identifier corresponding to this item. /// A unique identifier corresponding to this item.
String id; String? id;
String? error; String? error;
@ -13,8 +13,8 @@ class Model {
/// The last time at which this item was updated. /// The last time at which this item was updated.
DateTime? updatedAt; DateTime? updatedAt;
Model({required this.id, this.createdAt, this.updatedAt}); Model({this.id, this.createdAt, this.updatedAt});
/// Returns the [id], parsed as an [int]. /// Returns the [id], parsed as an [int].
int get idAsInt => int.tryParse(id) ?? -1; int get idAsInt => id != null ? int.tryParse(id!) ?? -1 : -1;
} }

View file

@ -1,5 +1,5 @@
name: angel3_model name: angel3_model
version: 3.0.1 version: 3.0.2
description: Angel3 basic data model class, no longer with the added weight of the whole framework. description: Angel3 basic data model class, no longer with the added weight of the whole framework.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/model repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/model