I just cant seem to figure out the wording in appgyver docs. i want to take all the items in a list of texts, and insert them as the value of a key in a list of objects. HOW, please?
You could maybe use a formula like this:
MAP<object>(listOfObjects, SET_KEY(object, "keyToSetValueTo", listOfTexts[index]))
The above formula, however, implies that the order in the list of Texts is the same as the order of the list of objects. If You need to add some kind of search to assign the correct values to each I guess that can also be included in the formula. It usually is possible.
when you say “MAP,” what goes in place of object, the object the data is being pulled from or the new list?
That is just an alias that is used inside of the formula instead of the “item”
ok, how about index between the brackets? Am i supposed to get a count and use the correct number there?
No, the index is the index of the current item and that should be known by the formula. You do not have to create a manual index.
so are you saying to keep the word “index” in the brackets? If so it is not working. Oh, and it is actually a list of texts i am grabbing data from. are they still object because firebase inserts a 0,1,2,…etc?
Exactly, keep it inside the brackets. What do You mean by it is not working? Could You please elaborate more on the issue?
If You use the Firebase Connector that is a list of texts, as that is not an object. Firebase 0,1,2 are just the indexes of the specific items in the list (either it is a text, object or whatever).
So would the formula be different than above for a list of texts?
I have a collection of posts.
Within each post is a nested array, like this:
likes (array)
Sfghnanakdkeieiekkrkrkd
Hhssjsmmsmdmskskske
Hshsjnsmdmdmdmsmsm
(In firebase it shows the numbered indexes)
I am trying to get the list, add the user id who is liking the post to the list, and push the list back to firebase in http request, because I read you cannot use the rest API to add a single item to an array.
Once the list is pushed back to firebase, I want to update that specific post node, so that the count of the items in the nested array immediately shows.
The weirdest thing is, I cannot reiterate over each item in the array in the formula editorz so I am just trying to use a variable with a list of objects to give it proper form for firebase, like this:
stringValue : Ghshjsjsmsmsmammamsm
So I need to get the list if texts, insert the text items as the value of each “stringValue” key, add the new userobject to the list, and push back to firebase.
Then I need to figure out how to update the count on only that item instead of having to get the entire collection, which slows things down for user.
Well, I have not really used the direct rest api integration of Firebase, so here I might not be a lot of help. But what I can say for sure is that this last point seems to me to be different as the original question.
So You have an array, You get the array values and if a user “likes” a post, You add the user ID to the array and update the original post firebase document’s “likes” property, which is an array, or am I missing something?
On the client side to render the total count of likes it would be a simple COUNT(data.post.likes), where data.post.likes is the array of user IDs who liked the post.
yea I already knew that, and I found the problem with the mapping. For some reason it will not work until the list page variable is initiated with an empty value. crazy
I was just trying to give you an overall of what i was trying to achieve per chance you may have known a better overall method.