Hi!
I have this flow that sends data from the firestore to the split node, which separates each key, so I have this function that creates a string using the keys and sends it to another node of the firestore, so I can put this string in the "collection" field and receive the data for a specific place.
The first thing you need to do is to tell us which Firestore node you are using. Probably node-red-contrib-something. I don't use Firestore, but since no-one else has answered possibly no-one here does, but if you tell us which node it is I will have a look and see if I can help.
But, I made a new node with the name of the collection that I have in common ("user"), and all the document information really came to me, I would now need to separate this data.
I managed using the switch node. But, in the case below, can I take all the objects that start with "User1" and generate a single json object? So there would be two outputs, one json with all "User1" objects and the other with all "User2" objects.
Can I just help to get you off on the correct terminology here which may help to avoid confusion. A JSON object is always a string. It is a string representation of a javascript object. JavaScript Object Notation. So what you are trying to create here is a javascript object, not JSON.
In a Function node you can use Object.entries() to give you an array of key/value pairs. Object.entries() - JavaScript | MDN
Then you can go through them and check the keys (which will be "User1", "User1a" etc and build two arrays out of those.
What I really wanted to do was find the name of the key, and if that key starts with "User1", create a unique object with everyone, like {"User1a": {}, "User1b": {}, "User1c": {}}, I'm not sure if Object.entries () can help me with this.
Anyway, I am really grateful for the help @Colin, really.
In a function node put msg.payload = msg.payload.entries() return msg
and feed it into a debug node to see what it gives you. It should give you what you are asking for as an array, which you can split into two arrays for user 1 and 2 and then if you really need to put back into an object.
But surely firestore can do this for you if you ask it the right questions.