create without id

This commit is contained in:
Tobe O 2018-10-21 12:26:53 -04:00
parent 6ed5f764d8
commit e24c89f8d9
2 changed files with 9 additions and 1 deletions

View file

@ -38,7 +38,8 @@ class RedisService extends Service<String, Map<String, dynamic>> {
else { else {
var keyVar = await respCommands.client var keyVar = await respCommands.client
.writeArrayOfBulk(['INCR', _applyPrefix('angel_redis:id')]); .writeArrayOfBulk(['INCR', _applyPrefix('angel_redis:id')]);
throw keyVar; id = keyVar.payload.toString();
data = new Map<String, dynamic>.from(data)..['id'] = id;
} }
await respCommands.set(_applyPrefix(id), json.encode(data)); await respCommands.set(_applyPrefix(id), json.encode(data));

View file

@ -20,4 +20,11 @@ main() async {
var output = await service.create(input); var output = await service.create(input);
expect(input, output); 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'));
});
} }