简体   繁体   English

REST API-对大量对象的CRUD操作

[英]REST API - CRUD operations on bulk of objects

I am designing a RESTful API and would like to understand how to perform CRUD operations on bulk of objects. 我正在设计一个RESTful API,并且想了解如何对大量对象执行CRUD操作。

For example, I would like to delete 30 users at once . 例如,我想一次 删除30个用户 How to design such an option in terms of REST API ? 如何根据REST API设计这样的选项? Or may be this is not a good practice ? 还是这不是一个好习惯

Thoughts? 有什么想法吗?

You can design it in this way. 您可以通过这种方式进行设计。

@Path("/users")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteUsers(args) {
.........
}

You can pass your list of users in a json (forexample user ids) as part of your request. 您可以在json中传递用户列表(例如,用户ID)作为请求的一部分。

or you can use matrix params to pass the list of user ids (if the number of users are less). 或者,您也可以使用矩阵参数来传递用户ID列表(如果用户数量较少)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM