How many number of key-value pairs in a map I can store in a Firestore document?

Vince Melmar Ybañez
User
--user1
  --fullName: "James Gosling"
  --messages
    --messageId1: true,
    --messageId2: true,
    --messageId3: true
--user2

I just want to store the id of each messages inside the user document so that whenever I want to update the fullName of a user, I just have to fetch those message ids and create a batched write to update the user's fullName in User Collection and Messages Collection. So how many number of key-value pairs in a Map field I can store?

Dharmaraj

There isn't a fixed limit but Firestore recommends having less than 100 fields per document. A document also has a max size limit of 1 MB.

By default, Cloud Firestore automatically maintains single-field indexes for each field in a document and each subfield in a map.

Creating many sub-fields with different keys will also index them. You can add exemptions however your message IDs seem be totally random and I doubt if you'll know them beforehand.

If you just want to store the message IDs, then you can use an array instead:

{
  username: "test",
  messageIds: ["messageId1", "messageId2"]
}

Alternatively, you can store user's UID in the message documents and then update the documents sent by the user so you don't have to worry about the document size limit. This Gist might be helpful to write that function.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I map a Firestore document to a struct?

How can I store key-value pairs in JSON to be deserialized in Java?

How to find the number of (key , value) pairs in a map in scala?

how many key value pairs an object can handle?

How do I pass the Map key value pairs in HttpRequest header?

How to map key/value pairs of a "map" in JavaScript?

How to store key value pairs in MySQL?

How to store key value pairs in SharedPreferences?

How can I make document field = map in Firestore?

How can I use gson to create a set of key value pairs?

How can I add values in key value pairs generated in scala

How can I create a table from key-value pairs?

How can I extract these key/value pairs from this JSON node?

How can I merge two dictionaries with multiple key value pairs

How can I access random key value pairs with JS?

How can I retreive all the fields from a firebase document to a map or Key: Value pair

Can I store HashSet to Firestore document (Java)

Can and should I store key-value pairs with localized UTF-8 characters?

How can I increase the value of a Firestore subcollection-document-field?

How do I store a Firestore document locally?

How can I count the number of keys with same values in a map, and store it?

Can I create an unordered_map of string and atomic<int> key-value pairs?

How should I store ~400 key-value pairs for my Android app?

How should I store 500 key-value pairs in a legacy database?

How can I get a map value inside a array from Firestore?

How can I store in a variable the Firestore document data what I read from the database?

How can you map an array to a new array based on the key-value pairs in an object?

How can I enumerate a hashtable as key-value pairs / filter a hashtable by a collection of key values

How to pass an unknown number of values as a key in key value pairs? (Javascript)

TOP Ranking

HotTag

Archive