RethinkDB delete multiple records by IDs at once

22 views Asked by At

Is there a way to delete multiple records at once by list of ids?

I am thinking of something like:

r.table("tableName").getAll(r.args(ids)).delete()

I can do deletion of multiple records but it is by doing 1 query to get the list of records to delete, then loop to each record and delete it.

I want to delete it at once given the list of ids to remove.

This works, but the deletion is 1 by 1:

List<Object> results = rethinkTemplate.runAsCursor(
                    rethinkTemplate.table(AgogoDancers.TABLE)
                        .between(papSmearStart, papSmearEnd)
                        .optArg("index", "timestampTime")
                        .getField(AgogoDancers.FIELD_ID)
                        .limit(limit));

results.stream()
    .filter(Objects::nonNull)
    .filter(result -> result instanceof String)
    .forEach(result -> rethinkTemplate.delete(AgogoDancers.TABLE, result.toString()));
0

There are 0 answers