You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/30 03:47:27 UTC

[GitHub] [apisix] bzp2010 commented on a diff in pull request #7778: feat: remove useless field in Admin API v3

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


##########
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:
   Yes, I also suffer from it, sometimes I do field overwriting and it does not take effect, the problem is strange.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org