From e24c89f8d9966d1e399881d63cc8cf9092ed1781 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 21 Oct 2018 12:26:53 -0400 Subject: [PATCH] create without id --- lib/src/redis_service.dart | 3 ++- test/all_test.dart | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/redis_service.dart b/lib/src/redis_service.dart index 878e5282..882dffbc 100644 --- a/lib/src/redis_service.dart +++ b/lib/src/redis_service.dart @@ -38,7 +38,8 @@ class RedisService extends Service> { else { var keyVar = await respCommands.client .writeArrayOfBulk(['INCR', _applyPrefix('angel_redis:id')]); - throw keyVar; + id = keyVar.payload.toString(); + data = new Map.from(data)..['id'] = id; } await respCommands.set(_applyPrefix(id), json.encode(data)); diff --git a/test/all_test.dart b/test/all_test.dart index 448d7212..50d0d536 100644 --- a/test/all_test.dart +++ b/test/all_test.dart @@ -20,4 +20,11 @@ main() async { var output = await service.create(input); expect(input, output); }); + test('create without id', () async { + var input = {'bar': 'baz'}; + var output = await service.create(input); + print(output); + expect(output.keys, contains('id')); + expect(output, containsPair('bar', 'baz')); + }); }