Creating FIrestore Maps from the console - firebase

I've seen a post on how to create a Map in the Firebase console for the realtime database, but how do you create a Map (in order to create a mutable/queryable list structure) in Firebase from the console? This is in order to create dummy data without doing so from the client.

Firestore documents are essentially JSON, and JSON doesn't have a native map data type. The most direct mapping is to create a JSON object:
Now you can add the keys and values under the new field.

You can now create a map type in Firebase:

Related

Retrieving data from firestore and storing it in a list (flutter)

I'm trying to retrieve data from firebase firestore so I can use it to display search reults by name inside my app. I've tried everything but still didn't work for me, any help?
Here are My search class And My Firestore Database.
Use: searchSnapshot!.docs[index].data()["userName"] and searchSnapshot!.docs[index].data()["userEmal"]
data isn't a variable; it is a method so the brackets are required.

How to retrieve data from List stored as a field of document/collection in Cloud Firestore?

[{},{},{},{}] <-- How to retrieve and map this data in widget using ListView.builder() in Flutter.
enter image description here
I am trying something like this
You are querying Users collection Instead of QuizHistory. And if you want to access a particular field in a map, you can define a Model class for it or, if you want to do it manually, you can do it as follows:
Text(snapshot.data['History'][index]['std'])

Cloud firestore - Order by nested data

I am new to Firebase cloud firestore. My database structure looks something like in the picture below. So, basically I have got a document for 'Liked' which tracks the timestamp at which user has liked the content. It has got 'chapter' as subcollection and inside each chapter there are sub-chapters which has the actual timestamp. Now I want to retrieve all the liked data ordered by the timestamp. I am not sure how can I achieve this!
You may use orderBy() to specify the sort order for your data like shown in the following example:
db.collection("liked").orderBy('timestamp').get()
I would also suggest you to follow this doc, it demostrates how to set up Cloud Firestore, add, read data and secure data.
UPDATE
I created the following database to replicate your scenario:
reprod(collections)/
test1(document)/
liked(collections)/
0(document)/
type(filed)
To stream the timestamps in ascending order I iterated manually to the doc and fetched the data ordered by timestamp:
reprod = db.collection(u'reprod').document(u'test1').collection(u'liked')
timestamps = reprod.stream()
for doc in timestamps:
print(f'{doc.id} => {doc.to_dict()}')
To do that I used the Firestore documentation on how to retrieve data and how to order data.

How to receive the changes from nested firestore collections into a single flutter stream?

For example when we need to read the changes in all cities (a subcollection under the country collection) using the following path:
Countries/{country_id}/cities/{city_id}
For each country_id we need a separate stream. How to receive changes in cities in a single stream for all countries?
Use a collection group query. On Flutter, you will want to use the collectionGroup() method to create that query.
firestore.collectionGroup("cities")

how to retrieve data from fire-store document collection data with out mentioning specific collection name?

I am working on angular 5 with firebase firestore.I inserted data into fire-store collection/document/collection/document/collection/document then set data the last document.But at the time retrieving data I am giving only first collection name then I want complete root data.but I am getting only field in it.
https://firebase.google.com/docs/firestore/query-data/get-data
checkout:List subcollections of a document
As we know querying in Cloud Firestore is shallow by default. This type of query isn't supported, although it is something Google may consider in the future.

Resources