This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -116,14 +116,13 @@ import 'dart:convert';
116
116
117
117
api.get("/favorites", (ctx) async {
118
118
// Get a list of all the keys in the store
119
- var keyStream = await favoritesKV .keys();
119
+ var keys = await favouritesKV .keys();
120
120
121
- // Convert the keys to a list of favorites
122
- var favorites = await keyStream.asyncMap((k) async {
123
- final favorite = await favoritesKV.get(k);
121
+ var favourites = await Future.wait(keys.map((k) async {
122
+ final favourite = await favouritesKV.get(k);
124
123
125
- return favorite ;
126
- }).toList();
124
+ return favourite ;
125
+ }).toList()) ;
127
126
128
127
// Return the body as a list of favorites
129
128
ctx.res.body = jsonEncode(favorites);
@@ -147,10 +146,10 @@ api.post("/favorite", (ctx) async {
147
146
final favorite = favorite.fromJson(req);
148
147
149
148
// search for the key, filtering by the name of the favorite
150
- final stream = await favoritesKV.keys(prefix: favorite.name);
149
+ final keys = await favoritesKV.keys(prefix: favorite.name);
151
150
152
151
// checks if the favorite exists in the list of keys
153
- final exists = await stream .any((f) => f == favorite.name);
152
+ final exists = keys .any((f) => f == favorite.name);
154
153
155
154
// if it exists delete and return
156
155
if (exists) {
You can’t perform that action at this time.
0 commit comments