How to delete all documents in a collection?
And is this explained in the documentation somewhere?
Thanks.
How to delete all documents in a collection?
And is this explained in the documentation somewhere?
Thanks.
@Melody, welcome to the Fauna Community.
There are couple of ways to delete a collection.
Delete
the collection. More Info
Read through Collection
and Delete
each document like shown below. Few things to be pointed.
Collection level Index
(with no terms) exists.Paginate
size is 64
. You will have to adjust the size
(max: 100000) depending on the number of documents in the Collection.Write Ops
.Map(
Paginate(
Match(Index("all_users"))
),
Lambda("X", Delete(Var("X")))
)
I went through this just now, looking to find a one-click button to empty everything. This is just what I did:
Map(
Paginate(
Documents(Collection('myCollection')),
{ size: 9999 }
),
Lambda(
['ref'],
Delete(Var('ref'))
)
)
No need for an index.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.