From 6ed5f764d88c9833c756187b29c60e66c6c316b5 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 21 Oct 2018 12:23:08 -0400 Subject: [PATCH] Create with id passes --- lib/src/redis_service.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/src/redis_service.dart b/lib/src/redis_service.dart index 80517f80..878e5282 100644 --- a/lib/src/redis_service.dart +++ b/lib/src/redis_service.dart @@ -29,6 +29,22 @@ class RedisService extends Service> { } } + @override + Future> create(Map data, + [Map params]) async { + String id; + if (data['id'] != null) + id = data['id'] as String; + else { + var keyVar = await respCommands.client + .writeArrayOfBulk(['INCR', _applyPrefix('angel_redis:id')]); + throw keyVar; + } + + await respCommands.set(_applyPrefix(id), json.encode(data)); + return data; + } + @override Future> update(String id, Map data, [Map params]) async {