Firestore and List of Objects

Hi all… I have been looking at this all day now… need heeeeelp :weary:

Not sure where I do things wrong, but here it goes…

In my app I have an App Variable as a list of objects with id, Counter, Language

In my Firestore DB I want to store these values under each user. In my user collection there is a document for each user. Where I currently have a field called EroLangArray.


I am not totally sure this is the right way to store a list of objects in Firestore?!? But using the ‘map’ type in a new field, I managed to be able to create the field Counter, LangID and Language (Counter and LangID are numbers and Language is Text - same in the previous mentioned app variable)

I have a Data Resource called “Users”, that connects to the Users Collection in Firestore. This works just fine, and I can get all the user data.

Some hours ago, I had an API configuration for the data schema, where I had “EroLangArray” as a list of objects. Counter, LangId and Language was set with their respective data formats. This worked fine for getting data. I could use to repeat a List item, and I could access the data just fine.

When I wanted to update the records with new values, I simply just cant write the new data back. Every time I get an error: "ReferenceError : Can’t find variable: Buffer"
(I use the Update Record" Flow function to do this.)

For fun / testing / debugging, I tried to create a new record instead, using the Create Record Flow function. Same result… "ReferenceError : Can’t find variable: Buffer"

If I remove the configuration of the EroLangArray, and try to update records and create new records, everything works fine. So it is fair to assume, that the issue is with my array of objects?

When there is a reference to EroLangArray in the Schema, no updates or creates work. (I can still read data - and use it for repeats and use data on labels etc…)
Even if I create a new record with just a Name and no data in the EroLangArray, it still fails…


I tried to connect to the data via the REST API… Just to see the auto generated schema. And it looks like this:


So I have manually recreated this schema now, in my “Users” Firestore connection.

It is a bit long… Here is a part of it:

And currently my Update / Create Record looks like this for the EroLangArray

Custom list looks like this:


  1. Am I storing lists of objects correctly in Firestore? There aren’t the many options…

  2. Should the update / create functions work just fine with my first basic schema?

  3. Is it really necessary to create this crazy long and complicated scheme?

  4. What is the easiest way to write a list of objects to the database?

Any other input, suggestions and naturally solutions will be much appreciated!

Thanks for take the time - Michael

1 Like

Hi, here’s a working example! items is an array, and the items are of type map.

In Composer, the schema for Products is:

type: text
items: list of objects with properties manufacturer: text and price: number

I created a “Collection of records” type data variable from the Firestore resource called Products, and I’m using the ENCODE_JSON() formula here to show it as a string in a paragraph component:


Hope this helps you get forward!

1 Like

Hi Mari,
thanks for the explanation and the screenshot from firestore.

Still the part about retrieving the data into AppGyver is to fast for me :wink:

  • when you say “I created a list type data variable called …”

a) composer allows me to create e.g. a data varialbe ‘Collection of data records’, but this is not a list

b) composer also allows me to create a page variable with value type ‘list’ , but this is not a data variable.

I am confused about how to bring these two parts together :hushed:

1 Like

Hi, sorry I meant the “Collection of records” type :slight_smile:


Hey @Mari - Thank you so much! Will give it a try asap :slight_smile:


1 Like

Hello again @Mari

I have tried to walk through your explanation - but I have to admit that I simply don’t get it… Sorry. I am trying hard here to understand what your thoughts were… any chance you can fill in some more screenshots?

Another thing is, that this seems to retrieve the data, which I already managed to do… My real issue is when I try to write / update the records.
Any thoughts on that?


1 Like

Hi, that’s ok! If you are unfamiliar with using data in Composer, I’d start from watching these videos.

Here’s how I would create a new record with the example setup:

Here I’m just binding it to a static value {type: "mouse", items: [{manufacturer: "Dell", price: 30}]}

When I click the “Create record” button in the web preview and refresh the page, “Products” has updated to include the mouse type:

Similarly, I can update the records using the “Update record” flow:

I have put in the ID of the record I just created as identifier, and set the record to {type: "mouse", items: [{manufacturer: "Dell", price: 50}]}

Again, the data changes accordingly:

This example is a bit dumb in the way that it uses static value bindings, but you can make use of variable bindings in your app to get the data from for example user input in a form. :slight_smile:

Hi @Mari,

Thank you for elaborating. However, it still does not work for me…

Not sure what you mean by:

it looks like you bind the value through the binding editor…(I can’t see a way to use a static value here)

This is mine:

this is my list of values:

When I push the button, I get this error (same as in my initial post):

As you can see above / behind my error message I do get the data with the ENCODE_JSON-way.

What am I doing wrong here… I am going crazy :wink:


How are you connecting to Firebase? Are you using the connector as instructed in this video?

Hi, I watched the videos and even the “working with objects” video but I can’t find were can I set this items: list of objects with properties in the schema, can you please tell me were I can set this?
Thank you

HI @Maxwell_Swamy , first, create the items property, then set its type to “List” and then the “List item type” to “Object” – then you can add the object properties.

1 Like

Thank you it worked,
Is there a way to get this data as a list of separated rows for every item inside there? to show it clear to the app user?

Thanks in advance.

Is there any way to sort the data variables in descending order?

Hi @Mari. I recreated your example. But can’t get it to work. I can update the “type” field just fine, but can’t do it with array of maps. Would you please take a look at my screenshots?

I also tried building the object manually but had no success.

Hi Mari,

I have had a look at this and in web preview my firebase create record works but as soon as I do it in the app preview it doesn’t work on my iphone. Is there a dependance that I am missing because teh error I get is “ReferenceError:Cant find Variable: Buffer”

Thanks for the detailed explanation @Mari
Works fine, I can create record but the problem is bellow, red marked portion.

Whenever I press record button, it create new document record with item index “0” always, Not with index 1,2,3… I want like in the pic above. Whenever a same user create record it should always goes under the same item with new index number, not a new document.


I manually create a record on my firebase database like shown above and try to get the item to my preview app by binding, there also I can bind only the type: to my value field by repeating the item. But when I try to bind the item: (list of object with two properties) to one text and a number field… I says “incompatible”… then how can I retrieve that data to my app… pic bellow.

In simple, a user can favorite some items from the list of items, that should store under his documents( I can create the document ID unique for each signed in user, fine for me).

Questions as a newbie…

  1. How can I to create multiple record under items with indexes 0,1,2,3… explained above.
  2. If first question is solved then how to retrieve that to app.

Hopefully get my answer from you.

I think @Mihaly_Toth @Cecilia @F_ORTELL can give some good solution to this…

Man, there is a huge misunderstanding and lack of database structure in this case…

If You want to build a list of products You have two options:

  1. Create a new document for each product if the list is to be increased in the future. (with properties like type, manufacturer, price, etc.)
  2. Create 1 document with a list of products with different properties as You did above. Now, this causes some issues in the data retrieval as You have to understand how data is structured pretty well to use that.

For the first question, Your solution would be binding in the “Update record” logic flow to “Object with custom properties”. Why update the record? Because You already have that and want to add a new item into that. So inside the “Object with properties” you will need to set the items property to a formula something like this:

WITH_ITEM(data.yourCategoryDocument.items, pageVars.newItemToAdd)

Make sure to change the formula inputs to your variables…

For the second question… You try to repeat a text with the “documents” list. But Your document has another list with which You should repeat the text. So what You would need to do is to change the “Repeat with” property of the text 7 component to the data.yourCategoryDocument.items

I guess that is all I can help with. Please learn a little more about data structures to avoid issues like these. The time spent on that will pay off. :pray:

Thanks for your time & detailed explanations @Mihaly_Toth

But the above formula binding not works for me. I’ll screenshot bellow for better understanding. Now I moved little further by searching many articles, that now I can retrieve the data to my app by nested repeating. That’s fine, I can update the particular value if I use the curresponding document ID by using pageVars binded to my “object with properties” custom list “items”.

Still the main problem exist until now…
I want to add/update a particular item(list of object with properties) inside the arrayValue by using conditions(if the document id is same/if the same object exist add a new one like so) as explained above. Am totally lost here…

This is what it says when I try with the formula that you said. There is may orange objection messages appears. Even I save and try it wont work. The formula binded property shows “null”.

If I use pageVars to bind instead of your formula it update the record according to the id that I provided. Even though, I cannot apply conditions to add another object list(like 0,1,2,…)

Hoping the best…

Well, you try to add an item that is not an object inside a list of objects… Also You have a list of objects and a list of objects. And You want to add one object from the second list of objects? I mean I am also lost there. Why would you want to do that?
Your page variable “Products” is a list of objects. Your data variable Products is a list of objects. What is the goal that You want to do?

What is the difference between pageVars.Products and data.Products.items???

Another note. If You have the price as a number and You assign its value from an input field I suggest using a NUMBER() formula as the input field may return the number as a string. This can also cause a few problems when saving data.