code | type | title |
---|---|---|
true |
page |
spop | API | Core |
Removes and returns one or more elements at random from a set of unique values. If multiple elements are removed, the result set will be an array of removed elements, instead of a string.
URL: http://kuzzle:7512/ms/_spop/<_id>
Method: POST
Body:
{
// optional
"count": 2
}
{
"controller": "ms",
"action": "spop",
"_id": "<key>",
"body": {
// optional
"count": 2
}
}
_id
: key identifier
count
: number of elements to remove (default:1
)
If count
is not set or equal to 1
, returns the removed element as a string:
{
"requestId": "<unique request identifier>",
"status": 200,
"error": null,
"controller": "ms",
"action": "spop",
"collection": null,
"index": null,
"result": "<removed element>"
}
If multiple elements are removed (count > 1
), an array of removed elements is returned instead:
{
"requestId": "<unique request identifier>",
"status": 200,
"error": null,
"controller": "ms",
"action": "spop",
"collection": null,
"index": null,
"result": [
"removed element 1",
"removed element 2",
"..."
]
}