Firestore: Version history of documents












0














I'm looking for a proper way to structure Firestore database to handle multiple version histories of documents inside a single collection.



For example: I have a collection named offers which have multiple documents which correspond to multiple offers. For each of these documents, I'd like to have history of changes, something like changes on Google Docs.



Since documents support only adding fields directly or nesting another collection, here's a structure I had in mind:



collections: offers
- documents: offer1, (offer2, offer3, ...)
- fields populated with latest version of the offer content
- nested collection named history
- nested documents for each version (v1, v2, v3), which in turn have fields specifing state of each field in that version.


This seems a bit overly complicated since I have latest state and than nested collection for history. Can this be somehow in flat structure where latest item in array is the latest state, or something similar.



Also, history state is generated on a button click, so I don't need every possible change saved in a history, just snapshots when user saves it.



I'd like to use Firebase as my DB for this, as I need it some other things, so I'm not looking into different solutions for now.



Thanks!



EDIT: According to the Alex's answer, here's my another take on this.



Firestore-root
|
--- offers (collection)
|
--- offerID (document)
| (with fields populated )
| |
| --- history (collection) //last edited timestamp
| |
| --- historyId
| --- historyId
|
--- offerID (document)
(with fields populated with latest changes)
|
--- history (collection) //last edited timestamp
|
--- historyId
--- historyId


This way I can query whole offers collection and get array of offers together with latest status since it's on the same level as the collection itself. Then if I need specific content from history state, I can query history collection of specific offer and get it's history states. Does this make sense?



I'm not sure about denormalization as this seems like it solves my problem and avoids complication.



Once more, requirements are:
- being able to fetch all offers with latest state (works)
- being able to load specific history state (works)



Just every time I update history collection with new state, I overwrite the fields directly in offerID collection with the same, latest, state.



Am I missing something?










share|improve this question





























    0














    I'm looking for a proper way to structure Firestore database to handle multiple version histories of documents inside a single collection.



    For example: I have a collection named offers which have multiple documents which correspond to multiple offers. For each of these documents, I'd like to have history of changes, something like changes on Google Docs.



    Since documents support only adding fields directly or nesting another collection, here's a structure I had in mind:



    collections: offers
    - documents: offer1, (offer2, offer3, ...)
    - fields populated with latest version of the offer content
    - nested collection named history
    - nested documents for each version (v1, v2, v3), which in turn have fields specifing state of each field in that version.


    This seems a bit overly complicated since I have latest state and than nested collection for history. Can this be somehow in flat structure where latest item in array is the latest state, or something similar.



    Also, history state is generated on a button click, so I don't need every possible change saved in a history, just snapshots when user saves it.



    I'd like to use Firebase as my DB for this, as I need it some other things, so I'm not looking into different solutions for now.



    Thanks!



    EDIT: According to the Alex's answer, here's my another take on this.



    Firestore-root
    |
    --- offers (collection)
    |
    --- offerID (document)
    | (with fields populated )
    | |
    | --- history (collection) //last edited timestamp
    | |
    | --- historyId
    | --- historyId
    |
    --- offerID (document)
    (with fields populated with latest changes)
    |
    --- history (collection) //last edited timestamp
    |
    --- historyId
    --- historyId


    This way I can query whole offers collection and get array of offers together with latest status since it's on the same level as the collection itself. Then if I need specific content from history state, I can query history collection of specific offer and get it's history states. Does this make sense?



    I'm not sure about denormalization as this seems like it solves my problem and avoids complication.



    Once more, requirements are:
    - being able to fetch all offers with latest state (works)
    - being able to load specific history state (works)



    Just every time I update history collection with new state, I overwrite the fields directly in offerID collection with the same, latest, state.



    Am I missing something?










    share|improve this question



























      0












      0








      0


      1





      I'm looking for a proper way to structure Firestore database to handle multiple version histories of documents inside a single collection.



      For example: I have a collection named offers which have multiple documents which correspond to multiple offers. For each of these documents, I'd like to have history of changes, something like changes on Google Docs.



      Since documents support only adding fields directly or nesting another collection, here's a structure I had in mind:



      collections: offers
      - documents: offer1, (offer2, offer3, ...)
      - fields populated with latest version of the offer content
      - nested collection named history
      - nested documents for each version (v1, v2, v3), which in turn have fields specifing state of each field in that version.


      This seems a bit overly complicated since I have latest state and than nested collection for history. Can this be somehow in flat structure where latest item in array is the latest state, or something similar.



      Also, history state is generated on a button click, so I don't need every possible change saved in a history, just snapshots when user saves it.



      I'd like to use Firebase as my DB for this, as I need it some other things, so I'm not looking into different solutions for now.



      Thanks!



      EDIT: According to the Alex's answer, here's my another take on this.



      Firestore-root
      |
      --- offers (collection)
      |
      --- offerID (document)
      | (with fields populated )
      | |
      | --- history (collection) //last edited timestamp
      | |
      | --- historyId
      | --- historyId
      |
      --- offerID (document)
      (with fields populated with latest changes)
      |
      --- history (collection) //last edited timestamp
      |
      --- historyId
      --- historyId


      This way I can query whole offers collection and get array of offers together with latest status since it's on the same level as the collection itself. Then if I need specific content from history state, I can query history collection of specific offer and get it's history states. Does this make sense?



      I'm not sure about denormalization as this seems like it solves my problem and avoids complication.



      Once more, requirements are:
      - being able to fetch all offers with latest state (works)
      - being able to load specific history state (works)



      Just every time I update history collection with new state, I overwrite the fields directly in offerID collection with the same, latest, state.



      Am I missing something?










      share|improve this question















      I'm looking for a proper way to structure Firestore database to handle multiple version histories of documents inside a single collection.



      For example: I have a collection named offers which have multiple documents which correspond to multiple offers. For each of these documents, I'd like to have history of changes, something like changes on Google Docs.



      Since documents support only adding fields directly or nesting another collection, here's a structure I had in mind:



      collections: offers
      - documents: offer1, (offer2, offer3, ...)
      - fields populated with latest version of the offer content
      - nested collection named history
      - nested documents for each version (v1, v2, v3), which in turn have fields specifing state of each field in that version.


      This seems a bit overly complicated since I have latest state and than nested collection for history. Can this be somehow in flat structure where latest item in array is the latest state, or something similar.



      Also, history state is generated on a button click, so I don't need every possible change saved in a history, just snapshots when user saves it.



      I'd like to use Firebase as my DB for this, as I need it some other things, so I'm not looking into different solutions for now.



      Thanks!



      EDIT: According to the Alex's answer, here's my another take on this.



      Firestore-root
      |
      --- offers (collection)
      |
      --- offerID (document)
      | (with fields populated )
      | |
      | --- history (collection) //last edited timestamp
      | |
      | --- historyId
      | --- historyId
      |
      --- offerID (document)
      (with fields populated with latest changes)
      |
      --- history (collection) //last edited timestamp
      |
      --- historyId
      --- historyId


      This way I can query whole offers collection and get array of offers together with latest status since it's on the same level as the collection itself. Then if I need specific content from history state, I can query history collection of specific offer and get it's history states. Does this make sense?



      I'm not sure about denormalization as this seems like it solves my problem and avoids complication.



      Once more, requirements are:
      - being able to fetch all offers with latest state (works)
      - being able to load specific history state (works)



      Just every time I update history collection with new state, I overwrite the fields directly in offerID collection with the same, latest, state.



      Am I missing something?







      firebase google-cloud-firestore data-modeling






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 at 12:39

























      asked Nov 23 at 7:38









      Sebastijan Dumančić

      474212




      474212
























          1 Answer
          1






          active

          oldest

          votes


















          1














          In my opinion, your above schema might work but you'll need to do some extra database calls, since Firestore queries are shallow. This means that Firestore queries can only get items from the collection that the query is run against. Firestore doesn't support queries across different collections. So there is no way in which you can get one document and the corresponding history versions that are hosted beneath a collection of that document in a single query.



          A possible database structure that I can think of, would be to use a single collection like this:



          Firestore-root
          |
          --- offerId (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- //Offer details


          If you want to diplay all history versions of an offer, a single query is required. So you just need to attach a listener on offerId collection and get all offer objects (documents) in a single go.



          However, if you only want to get the last version of an offer, then you should add under each offer object a timestamp property and query the database according to it descending. At the end just make a limit(1) call and that's it!



          Edit:



          According to your comment:




          I need to get a list of all offers with their latest data




          In this case you need to create a new collection named offers which will hold all the latest versions of your offers. Your new collection should look like this:



          Firestore-root
          |
          --- offers (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- date: //last edited timestamp
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- date: //last edited timestamp
          |
          --- //Offer details


          This practice is called denormalization and is a common practice when it comes to Firebase. If you are new to NoQSL databases, I recommend you see this video, Denormalization is normal with the Firebase Database for a better understanding. It is for Firebase realtime database but same rules apply to Cloud Firestore.



          Also, when you are duplicating data, there is one thing that need to keep in mind. In the same way you are adding data, you need to maintain it. With other words, if you want to update/detele an item, you need to do it in every place that it exists.



          In your particular case, when you want to create an offer you need to add it in two places, once in your offerId collection and once in your offers collection. Once a new history version of an offer is created, there is only one more operation that you need to do. As before, add the offerHistoryId document in your offerId collection, add the same object in your offers collection, but in this case you need to remove the older version of the offer from the offers collection.






          share|improve this answer























          • Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
            – Sebastijan Dumančić
            Nov 23 at 12:04








          • 1




            Oh, I understand. I'll update my answer right away.
            – Alex Mamo
            Nov 23 at 12:06






          • 1




            Please see my updated answer.
            – Alex Mamo
            Nov 23 at 12:26






          • 1




            It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
            – Alex Mamo
            Nov 23 at 12:43






          • 1




            I'll look a bit more into it. Thanks for the help :)
            – Sebastijan Dumančić
            Nov 23 at 12:44











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442460%2ffirestore-version-history-of-documents%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          In my opinion, your above schema might work but you'll need to do some extra database calls, since Firestore queries are shallow. This means that Firestore queries can only get items from the collection that the query is run against. Firestore doesn't support queries across different collections. So there is no way in which you can get one document and the corresponding history versions that are hosted beneath a collection of that document in a single query.



          A possible database structure that I can think of, would be to use a single collection like this:



          Firestore-root
          |
          --- offerId (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- //Offer details


          If you want to diplay all history versions of an offer, a single query is required. So you just need to attach a listener on offerId collection and get all offer objects (documents) in a single go.



          However, if you only want to get the last version of an offer, then you should add under each offer object a timestamp property and query the database according to it descending. At the end just make a limit(1) call and that's it!



          Edit:



          According to your comment:




          I need to get a list of all offers with their latest data




          In this case you need to create a new collection named offers which will hold all the latest versions of your offers. Your new collection should look like this:



          Firestore-root
          |
          --- offers (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- date: //last edited timestamp
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- date: //last edited timestamp
          |
          --- //Offer details


          This practice is called denormalization and is a common practice when it comes to Firebase. If you are new to NoQSL databases, I recommend you see this video, Denormalization is normal with the Firebase Database for a better understanding. It is for Firebase realtime database but same rules apply to Cloud Firestore.



          Also, when you are duplicating data, there is one thing that need to keep in mind. In the same way you are adding data, you need to maintain it. With other words, if you want to update/detele an item, you need to do it in every place that it exists.



          In your particular case, when you want to create an offer you need to add it in two places, once in your offerId collection and once in your offers collection. Once a new history version of an offer is created, there is only one more operation that you need to do. As before, add the offerHistoryId document in your offerId collection, add the same object in your offers collection, but in this case you need to remove the older version of the offer from the offers collection.






          share|improve this answer























          • Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
            – Sebastijan Dumančić
            Nov 23 at 12:04








          • 1




            Oh, I understand. I'll update my answer right away.
            – Alex Mamo
            Nov 23 at 12:06






          • 1




            Please see my updated answer.
            – Alex Mamo
            Nov 23 at 12:26






          • 1




            It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
            – Alex Mamo
            Nov 23 at 12:43






          • 1




            I'll look a bit more into it. Thanks for the help :)
            – Sebastijan Dumančić
            Nov 23 at 12:44
















          1














          In my opinion, your above schema might work but you'll need to do some extra database calls, since Firestore queries are shallow. This means that Firestore queries can only get items from the collection that the query is run against. Firestore doesn't support queries across different collections. So there is no way in which you can get one document and the corresponding history versions that are hosted beneath a collection of that document in a single query.



          A possible database structure that I can think of, would be to use a single collection like this:



          Firestore-root
          |
          --- offerId (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- //Offer details


          If you want to diplay all history versions of an offer, a single query is required. So you just need to attach a listener on offerId collection and get all offer objects (documents) in a single go.



          However, if you only want to get the last version of an offer, then you should add under each offer object a timestamp property and query the database according to it descending. At the end just make a limit(1) call and that's it!



          Edit:



          According to your comment:




          I need to get a list of all offers with their latest data




          In this case you need to create a new collection named offers which will hold all the latest versions of your offers. Your new collection should look like this:



          Firestore-root
          |
          --- offers (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- date: //last edited timestamp
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- date: //last edited timestamp
          |
          --- //Offer details


          This practice is called denormalization and is a common practice when it comes to Firebase. If you are new to NoQSL databases, I recommend you see this video, Denormalization is normal with the Firebase Database for a better understanding. It is for Firebase realtime database but same rules apply to Cloud Firestore.



          Also, when you are duplicating data, there is one thing that need to keep in mind. In the same way you are adding data, you need to maintain it. With other words, if you want to update/detele an item, you need to do it in every place that it exists.



          In your particular case, when you want to create an offer you need to add it in two places, once in your offerId collection and once in your offers collection. Once a new history version of an offer is created, there is only one more operation that you need to do. As before, add the offerHistoryId document in your offerId collection, add the same object in your offers collection, but in this case you need to remove the older version of the offer from the offers collection.






          share|improve this answer























          • Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
            – Sebastijan Dumančić
            Nov 23 at 12:04








          • 1




            Oh, I understand. I'll update my answer right away.
            – Alex Mamo
            Nov 23 at 12:06






          • 1




            Please see my updated answer.
            – Alex Mamo
            Nov 23 at 12:26






          • 1




            It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
            – Alex Mamo
            Nov 23 at 12:43






          • 1




            I'll look a bit more into it. Thanks for the help :)
            – Sebastijan Dumančić
            Nov 23 at 12:44














          1












          1








          1






          In my opinion, your above schema might work but you'll need to do some extra database calls, since Firestore queries are shallow. This means that Firestore queries can only get items from the collection that the query is run against. Firestore doesn't support queries across different collections. So there is no way in which you can get one document and the corresponding history versions that are hosted beneath a collection of that document in a single query.



          A possible database structure that I can think of, would be to use a single collection like this:



          Firestore-root
          |
          --- offerId (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- //Offer details


          If you want to diplay all history versions of an offer, a single query is required. So you just need to attach a listener on offerId collection and get all offer objects (documents) in a single go.



          However, if you only want to get the last version of an offer, then you should add under each offer object a timestamp property and query the database according to it descending. At the end just make a limit(1) call and that's it!



          Edit:



          According to your comment:




          I need to get a list of all offers with their latest data




          In this case you need to create a new collection named offers which will hold all the latest versions of your offers. Your new collection should look like this:



          Firestore-root
          |
          --- offers (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- date: //last edited timestamp
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- date: //last edited timestamp
          |
          --- //Offer details


          This practice is called denormalization and is a common practice when it comes to Firebase. If you are new to NoQSL databases, I recommend you see this video, Denormalization is normal with the Firebase Database for a better understanding. It is for Firebase realtime database but same rules apply to Cloud Firestore.



          Also, when you are duplicating data, there is one thing that need to keep in mind. In the same way you are adding data, you need to maintain it. With other words, if you want to update/detele an item, you need to do it in every place that it exists.



          In your particular case, when you want to create an offer you need to add it in two places, once in your offerId collection and once in your offers collection. Once a new history version of an offer is created, there is only one more operation that you need to do. As before, add the offerHistoryId document in your offerId collection, add the same object in your offers collection, but in this case you need to remove the older version of the offer from the offers collection.






          share|improve this answer














          In my opinion, your above schema might work but you'll need to do some extra database calls, since Firestore queries are shallow. This means that Firestore queries can only get items from the collection that the query is run against. Firestore doesn't support queries across different collections. So there is no way in which you can get one document and the corresponding history versions that are hosted beneath a collection of that document in a single query.



          A possible database structure that I can think of, would be to use a single collection like this:



          Firestore-root
          |
          --- offerId (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- //Offer details


          If you want to diplay all history versions of an offer, a single query is required. So you just need to attach a listener on offerId collection and get all offer objects (documents) in a single go.



          However, if you only want to get the last version of an offer, then you should add under each offer object a timestamp property and query the database according to it descending. At the end just make a limit(1) call and that's it!



          Edit:



          According to your comment:




          I need to get a list of all offers with their latest data




          In this case you need to create a new collection named offers which will hold all the latest versions of your offers. Your new collection should look like this:



          Firestore-root
          |
          --- offers (collection)
          |
          --- offerHistoryId (document)
          | |
          | --- date: //last edited timestamp
          | |
          | --- //Offer details
          |
          --- offerHistoryId (document)
          |
          --- date: //last edited timestamp
          |
          --- //Offer details


          This practice is called denormalization and is a common practice when it comes to Firebase. If you are new to NoQSL databases, I recommend you see this video, Denormalization is normal with the Firebase Database for a better understanding. It is for Firebase realtime database but same rules apply to Cloud Firestore.



          Also, when you are duplicating data, there is one thing that need to keep in mind. In the same way you are adding data, you need to maintain it. With other words, if you want to update/detele an item, you need to do it in every place that it exists.



          In your particular case, when you want to create an offer you need to add it in two places, once in your offerId collection and once in your offers collection. Once a new history version of an offer is created, there is only one more operation that you need to do. As before, add the offerHistoryId document in your offerId collection, add the same object in your offers collection, but in this case you need to remove the older version of the offer from the offers collection.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 23 at 12:26

























          answered Nov 23 at 11:20









          Alex Mamo

          39.2k72758




          39.2k72758












          • Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
            – Sebastijan Dumančić
            Nov 23 at 12:04








          • 1




            Oh, I understand. I'll update my answer right away.
            – Alex Mamo
            Nov 23 at 12:06






          • 1




            Please see my updated answer.
            – Alex Mamo
            Nov 23 at 12:26






          • 1




            It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
            – Alex Mamo
            Nov 23 at 12:43






          • 1




            I'll look a bit more into it. Thanks for the help :)
            – Sebastijan Dumančić
            Nov 23 at 12:44


















          • Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
            – Sebastijan Dumančić
            Nov 23 at 12:04








          • 1




            Oh, I understand. I'll update my answer right away.
            – Alex Mamo
            Nov 23 at 12:06






          • 1




            Please see my updated answer.
            – Alex Mamo
            Nov 23 at 12:26






          • 1




            It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
            – Alex Mamo
            Nov 23 at 12:43






          • 1




            I'll look a bit more into it. Thanks for the help :)
            – Sebastijan Dumančić
            Nov 23 at 12:44
















          Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
          – Sebastijan Dumančić
          Nov 23 at 12:04






          Thanks Alex! I actually didn't know that you can't get deeply nested objects. Just tried and you're right. However, this structure also doesn't resolve all problems. For example, I need to get a list of all offers with their latest data, and here I don't see the way to do it since each offer is in it's own collection. I'm curious if you have a way about that. I can share my idea afterwards :)
          – Sebastijan Dumančić
          Nov 23 at 12:04






          1




          1




          Oh, I understand. I'll update my answer right away.
          – Alex Mamo
          Nov 23 at 12:06




          Oh, I understand. I'll update my answer right away.
          – Alex Mamo
          Nov 23 at 12:06




          1




          1




          Please see my updated answer.
          – Alex Mamo
          Nov 23 at 12:26




          Please see my updated answer.
          – Alex Mamo
          Nov 23 at 12:26




          1




          1




          It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
          – Alex Mamo
          Nov 23 at 12:43




          It is almost the same as the first one. IMHO, if I were you, I'll use denormalization. It's sounds a little weird but it's quite easy. You're welcome Sebastijan, cheers!
          – Alex Mamo
          Nov 23 at 12:43




          1




          1




          I'll look a bit more into it. Thanks for the help :)
          – Sebastijan Dumančić
          Nov 23 at 12:44




          I'll look a bit more into it. Thanks for the help :)
          – Sebastijan Dumančić
          Nov 23 at 12:44


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442460%2ffirestore-version-history-of-documents%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks