Updated models
This commit is contained in:
parent
7809c72f03
commit
86538f7af1
4 changed files with 36 additions and 8 deletions
|
@ -1,5 +1,11 @@
|
|||
# Change Log
|
||||
|
||||
## 7.1.0
|
||||
|
||||
* Return -1 instead of throwing exception when id is null
|
||||
* Added `idAsString` to return id or "" if null
|
||||
* Added `AuditableModel`
|
||||
|
||||
## 7.0.0
|
||||
|
||||
* Require Dart >= 2.17
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
# Angel3 Basic Data Model
|
||||
# Angel3 Data Model
|
||||
|
||||
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_model?include_prereleases)
|
||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
|
||||
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/model/LICENSE)
|
||||
|
||||
Angel3 basic data model class, no longer with the added weight of the whole framework.
|
||||
The basic data models for Angel3 framework.
|
||||
|
||||
```dart
|
||||
import 'package:angel3_model/angel3_model.dart';
|
||||
```
|
||||
|
||||
This package was created to prevent dependency collisions with third-party packages.
|
||||
The available data models are:
|
||||
|
||||
* `Model` class
|
||||
* A basic data model
|
||||
* `AuditableModel` class
|
||||
* A basic data model with audit log feature
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
//library angel3_model;
|
||||
|
||||
/// Represents arbitrary data, with an associated ID and timestamps.
|
||||
/// Represents a generic data model with an ID and timestamps.
|
||||
class Model {
|
||||
/// A unique identifier corresponding to this item.
|
||||
String? id;
|
||||
|
@ -14,5 +12,24 @@ class Model {
|
|||
Model({this.id, this.createdAt, this.updatedAt});
|
||||
|
||||
/// Returns the [id], parsed as an [int].
|
||||
int get idAsInt => id != null ? int.tryParse(id!) ?? -1 : -1;
|
||||
int get idAsInt => id != null ? int.tryParse(id ?? "-1") ?? -1 : -1;
|
||||
|
||||
/// Returns the [id] or "" if null.
|
||||
String get idAsString => id ?? "";
|
||||
}
|
||||
|
||||
/// Represents a generic data model with audit log feature.
|
||||
class AuditableModel extends Model {
|
||||
/// The authorized user who created the record.
|
||||
String? createdBy;
|
||||
|
||||
/// The user who updated the record last time.
|
||||
String? updatedBy;
|
||||
|
||||
AuditableModel(
|
||||
{super.id,
|
||||
super.createdAt,
|
||||
this.createdBy,
|
||||
super.updatedAt,
|
||||
this.updatedBy});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_model
|
||||
version: 7.0.0
|
||||
version: 7.1.0
|
||||
description: Angel3 basic data model class, no longer with the added weight of the whole framework.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/model
|
||||
|
|
Loading…
Reference in a new issue