# BatchOperation that allows a BatchGet and Delete?

**URL:** <https://discuss.aerospike.com/t/batchoperation-that-allows-a-batchget-and-delete/8141>\
**Category:** Go Client\
**Tags:** query, udf\
**Created:** [January 12, 2021, 11:28pm UTC](https://discuss.aerospike.com/t/batchoperation-that-allows-a-batchget-and-delete/8141 "2021-01-12T23:28:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xMartian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/0xmartian/32/1597_2.png) [@0xMartian](https://discuss.aerospike.com/u/0xMartian)\
**Post date:** [January 12, 2021, 11:28pm UTC](https://discuss.aerospike.com/t/batchoperation-that-allows-a-batchget-and-delete/8141/1 "2021-01-12T23:28:03Z")

</div>

New to the community and have been poking around the source code of the golang client library for a while.

I am wondering if there is a function to preform multiple operations using batchget. In the docs (and the code in client.go) there is a way to preform a Get and Delete in a single request to the database, but this functionality seems to not be there for a ‘BatchGet’. I am piecing together an idea that involves calling calling a stream UDF on the result of my batchget, but it seems the ‘aerospike way’ is to use the operations api.

Furthermore, is there a way to limit the amount of requests returned by a query? What is the aerospike way to retrieve records in batches without preforming a full scan? I have the taste of an idea that involves ending the stream inside a UDF once X number of records have passed through it, is this the right direction?

In short, looking for a BatchOperation that will allow a ‘BatchGet’ and ‘BatchDelete’ and a way to limit the amount of results from a query.

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [January 13, 2021, 11:08am UTC](https://discuss.aerospike.com/t/batchoperation-that-allows-a-batchget-and-delete/8141/2 "2021-01-13T11:08:53Z")

</div>

1. `BatchGet` is only to perform fetch operations.
2. You can perform multiple operations via `QueryExecute` adding `Policy.FilterExpressions`.
3. We are going to release a feature on the client soon that allow you to perform limited scans. At the moment, you can query and then close the `recordset` when you have enough records.

---

<div class="post-metadata">

**Author:** ![0xMartian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/0xmartian/32/1597_2.png) [@0xMartian](https://discuss.aerospike.com/u/0xMartian)\
**Post date:** [January 13, 2021, 10:20pm UTC](https://discuss.aerospike.com/t/batchoperation-that-allows-a-batchget-and-delete/8141/4 "2021-01-13T22:20:08Z")

</div>

Hey, im not sure how to chain commands through the FilterExpression. If I wanted to change the value of a bin for each record how would I do that?

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [January 14, 2021, 5:43pm UTC](https://discuss.aerospike.com/t/batchoperation-that-allows-a-batchget-and-delete/8141/5 "2021-01-14T17:43:07Z")

</div>

If you could mention your exact use case, I’d be able to to help you more specifically. If your use-case involves complicated operations or getting the results back right after change, the only way to do it would be to use a Stream UDF (with its performance implications) If it can be done using simple Operations and does not involve fetching back the results, then you can use `ExecuteQuery` via `FilterExpressions`. You can see examples here:

> <https://github.com/aerospike/aerospike-client-go/blob/master/expression_test.go>

Don’t hesitate to ask in case you have further questions.
