soulbird commented on code in PR #7778:
URL: https://github.com/apache/apisix/pull/7778#discussion_r957974650


##########
apisix/admin/v3_adapter.lua:
##########
@@ -181,8 +181,31 @@ function _M.filter(body)
 
     local args = request.get_uri_args()
 
-    pagination(body, args)
-    filter(body, args)
+    if body.deleted then
+        body.node = nil
+    end
+
+    -- strip node wrapping for single query, create, and update scenarios.
+    if body.node then
+        body = body.node
+    end
+
+    -- filter and paging logic for list query only
+    if body.list then
+        filter(body, args)
+
+        -- calculate the total amount of filtered data
+        body.total = body.list and #body.list or 0
+
+        pagination(body, args)
+
+        -- remove the count field returned by etcd
+        -- we don't need a field that reflects the length of the currently 
returned data,
+        -- it doesn't make sense
+        body.count = nil
+    end
+
+    return body

Review Comment:
   Can we create a new body and then populate its fields? I don't think it's 
intuitive to change fields on the old body structure. I can't see what the 
final output data structure looks like with the current code, it's really hard 
to maintain. cc @tzssangglass 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to