Create many documents in a collection
Solution
Use the Map
function to iterate over an array, and use the Create
function to create a new document for each item in the array:
[
{
ref: Ref(Collection("dilapidated_huts"), "329482154362798144"),
ts: 1650477518490000,
data: {
material: "straw"
}
},
{
ref: Ref(Collection("dilapidated_huts"), "329482154363846720"),
ts: 1650477518490000,
data: {
material: "sticks"
}
},
{
ref: Ref(Collection("dilapidated_huts"), "329482154363847744"),
ts: 1650477518490000,
data: {
material: "bricks"
}
}
]
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!