How can I delete all data with search terms?

I use this fql to delete my data,but only delete a few records.
Can anyone tell me what’s wrong with that?

Map(
  Paginate(Match(Index("plantform_story_top"), "x", "f")),
  Lambda("ref", Delete(Var("ref")))
)

CreateIndex({
  name: "plantform_story_top",
  unique: false,
  serialized: true,
  source: Collection("story_top"),
  terms: [
    {
      field: ["data", "t1"]
    },
    {
      field: ["data", "t2"]
    }    
  ]
})

By default, Paginate only returns a page with 64 results. You can request up to 100,000 with the size parameter:

Paginate(Match(Index("plantform_story_top"), "x", "f"), {size: 100000})

Or if there are more results than that, you could iterate through each page to delete the records until there were no more results in your set.

I just realized that your Match has the search terms as separate parameters, but I think they might have to be an array if there are multiple of them?

Match(Index("plantform_story_top"), ["x", "f"])

The JS driver lets you spread the arguments, so you don’t have to wrap arguments in an array with the JS driver or Shell.

That said, I think it’s more idiomatic to use an array. It can also be easier to reason about types if you avoid variadic functions, IMHO.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.