I have been trying to consolidate my UDFs for simplicity but a limitation I am finding is that I cant seem to find how to pass a variable for a projection into a UDF.
For example, I want to be able to create a generic UDF where I can pass the collection name and the full projection I want to receive back. I have been able to pass the collection name and get results, but cant figure out how to pass a full projection dynamically.
function recordGetList(coll, proj) {
let collection = Collection(coll)
collection.all() {proj} ← Fauna thinks I want the field proj here
}
I did figure out how to pass a single field into a UDF (example below), but cant figure out how to pass in a full projection for example {id, orderid, name, date, customer {name, custid}}
Here is where I am able to pass the field for the projection using [myvar]
function maxNum(coll, myvar) {
Collection(coll)
.all()
.map(x => x[myvar])
.order(asc(v => v))
.toArray()
.filter((x) => {x != null && x != “”})
.last()
}
I also didnt find the above [myvar] in the documentation anywhere, it was a suggestion from an AI program. If it exists in your documentation, it is really hard to find. I do think the documentation is still a serious limitation for adoption of your platform.