To answer your first question. I guess the problem is that you have to put quotes around $elemMatch
Your second one I can sadly not answer as it is not n8n related rather MongoDB specific and do honestly not have much experience with it at all. Maybe somebody else who does can be of more help here.
I did reformat your example above into multiple lines. Like you can see is there one } too much. So if you get the error message Unexpected token '}' you should be able to fix it if you remove the last one.
At least like that, it should be valid JSON for sure. If you still get an error message, it sounds like it would be also something MongoDB specific.
I talked with one of our devs, that sorting.limit etc cannot be done via json to mongoDB so i guess then the best way is to just processes the results in new function node and then sort and get the with latest date.
Again, I have sadly no idea as it is again MongoDB related. But if your developer is right (what I assume) then for now the Function-Node is the way to go. In the long-term we would have to add this missing functionality to the Mongo-Node.
On a side note: Please make sure to always mark code blocks like described here:
and also use the proper indentation. Only then do they get displayed correctly and it is easy to understand what is happening. Currently I always have to fix your posts manually which is quite time intensive. Thanks!
Sorry for disturbing again, we ware sitting, me dan the devs to try to solve the function but limit by function. We are still struggling with how to get the array. please see example below
Regarding the type sorry for that, must be when we copied the data.
What we are struggling with is to understand how to get the right data. We are trying to get the pattern based on the things you helped us with before. The challenge for us is to get when to use what.
Do you have any documentation on just data mapping into functions?
Great with all support from your side but of course we don´t want to be a burden for the community for those basics.
Ah yes can understand that. It definitely not as simply as I like it to be. Hope we can improve that in the future with additional nodes and improved documentation!
About existing documentation. Information about the general structure of data in n8n can be found here:
All the functions which exist and how they can be used is documented here:
Apart from that it is JavaScript programming with functions that are available there like the sort function you used above.
I hope that helps! But it is currently definitely not your “fault” if you have problems. Still much to improve from our side.