I’m trying to upsert an array of ~1000 documents to Fauna on a daily basis. I’ve written my query in FQL, where I match the new array with the existing collection based on the URL param, but for some reason, even if another document with that URL exists in my collection, the document still gets created.
var arrData = [
{
data: {
url: "https://www.example.com/in/nameOne/",
firstName: "First",
lastName: "Last",
}
},
{
data: {
url: "https://www.example.com/in/nameTwo/",
firstName: "First",
lastName: "Last",
}
}
]
q.Map(arrData, q.Lambda(['d'],
q.If(
q.Exists(
q.Match(q.Index('zap'), q.Select(['data', 'url'], q.Var('d')))
),
q.Replace(
q.Select(
'ref',
q.Get(
q.Match(q.Index('zap'), q.Select(['data', 'url'], q.Var('d')))
)
),
Var('d')
),
q.Create(q.Collection('users'), q.Var('d'))
)
))