This commit is contained in:
Tobe O 2019-04-17 17:03:10 -04:00
parent 48e294f5c2
commit 8eeae3c286
3 changed files with 15 additions and 7 deletions

View file

@ -1,3 +1,6 @@
# 2.0.1
* Pass everything through `_jsonifyToSD` when returning responses.
# 2.0.0
* Dart/Angel 2 update.
* Remove `package:dart2_constant`

View file

@ -60,17 +60,19 @@ class JsonFileService extends Service<String, Map<String, dynamic>> {
@override
Future<List<Map<String, dynamic>>> index(
[Map<String, dynamic> params]) async =>
_load().then((_) => _store.index(params));
_load()
.then((_) => _store.index(params))
.then((it) => it.map(_jsonifyToSD).toList());
@override
Future<Map<String, dynamic>> read(id, [Map<String, dynamic> params]) =>
_load().then((_) => _store.read(id, params));
_load().then((_) => _store.read(id, params)).then(_jsonifyToSD);
@override
Future<Map<String, dynamic>> create(data,
[Map<String, dynamic> params]) async {
await _load();
var created = await _store.create(data, params);
var created = await _store.create(data, params).then(_jsonifyToSD);
await _save();
return created;
}
@ -78,7 +80,7 @@ class JsonFileService extends Service<String, Map<String, dynamic>> {
@override
Future<Map<String, dynamic>> remove(id, [Map<String, dynamic> params]) async {
await _load();
var r = await _store.remove(id, params);
var r = await _store.remove(id, params).then(_jsonifyToSD);
await _save();
return r;
}
@ -87,7 +89,7 @@ class JsonFileService extends Service<String, Map<String, dynamic>> {
Future<Map<String, dynamic>> update(id, data,
[Map<String, dynamic> params]) async {
await _load();
var r = await _store.update(id, data, params);
var r = await _store.update(id, data, params).then(_jsonifyToSD);
await _save();
return r;
}
@ -96,7 +98,7 @@ class JsonFileService extends Service<String, Map<String, dynamic>> {
Future<Map<String, dynamic>> modify(id, data,
[Map<String, dynamic> params]) async {
await _load();
var r = await _store.update(id, data, params);
var r = await _store.update(id, data, params).then(_jsonifyToSD);
await _save();
return r;
}
@ -119,6 +121,9 @@ Map _jsonify(Map map) {
return map.keys.fold<Map>({}, (out, k) => out..[k] = _safeForJson(map[k]));
}
Map<String, dynamic> _jsonifyToSD(Map<String, dynamic> map) =>
_jsonify(map).cast<String, dynamic>();
dynamic _revive(x) {
if (x is Map) {
return x.keys.fold<Map<String, dynamic>>(

View file

@ -1,5 +1,5 @@
name: angel_file_service
version: 2.0.0
version: 2.0.1
description: Angel service that persists data to a file on disk.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/file_service