Firestore query document based on comparison of 2 fieldsFirestore : Retrieve a single documentFirestore query filter retrieve document where field is missingFirebase Firestore prevent client side creation of fields in a documentFirestore: How to query for non-existing (undefined) fields?Querying Firestore Data based on FieldValue.serverTimestamp() - Date ConditionQuery documents with string field in array on Cloud FirestoreSearch for documents with a field which is equal to any of one element in an arrayFirestore firebase Android search and update querySetting and retrieving server timestamp on FirestoreIs it ok to store a user id as the key of a field in a Firestore document?

When did game consoles begin including FPUs?

Why when I add jam to my tea it stops producing thin "membrane" on top?

Would life always name the light from their sun "white"

Why are lawsuits between the President and Congress not automatically sent to the Supreme Court

Formal Definition of Dot Product

Is there any good reason to write "it is easy to see"?

Wireless headphones interfere with Wi-Fi signal on laptop

Do people who work at research institutes consider themselves "academics"?

Can my American children re-enter the USA by International flight with a passport card? Being that their passport book has expired

How would you translate "grit" (personality trait) to Chinese?

How to not get blinded by an attack at dawn

tikz drawing rectangle discretized with triangle lattices and its centroids

What color to choose as "danger" if the main color of my app is red

Assembly writer vs compiler

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

Does it matter what way the tires go if no directional arrow?

What was Varys trying to do at the beginning of S08E05?

Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?

Will consteval functions allow template parameters dependent on function arguments?

Understanding Python syntax in lists vs series

Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?

How to rename multiple files in a directory at the same time

Why do galaxies collide?

Why commonly or frequently used fonts sizes are even numbers like 10px, 12px, 16px, 24px, or 32px?



Firestore query document based on comparison of 2 fields


Firestore : Retrieve a single documentFirestore query filter retrieve document where field is missingFirebase Firestore prevent client side creation of fields in a documentFirestore: How to query for non-existing (undefined) fields?Querying Firestore Data based on FieldValue.serverTimestamp() - Date ConditionQuery documents with string field in array on Cloud FirestoreSearch for documents with a field which is equal to any of one element in an arrayFirestore firebase Android search and update querySetting and retrieving server timestamp on FirestoreIs it ok to store a user id as the key of a field in a Firestore document?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Say I have this document



userProfile: 
createdAt: '2018-01-01',
updatedAt: '2018-01-04'



I want to retrieve all userProfiles that were updated after their creation, that means those that satisfy createdAt < updatedAt.

Can you do that in Firestore?



Something like this, but where the second operand is a field, not a value:



userProfileRef.where("createdAt", "<", "updatedAt")


Thanks










share|improve this question




























    0















    Say I have this document



    userProfile: 
    createdAt: '2018-01-01',
    updatedAt: '2018-01-04'



    I want to retrieve all userProfiles that were updated after their creation, that means those that satisfy createdAt < updatedAt.

    Can you do that in Firestore?



    Something like this, but where the second operand is a field, not a value:



    userProfileRef.where("createdAt", "<", "updatedAt")


    Thanks










    share|improve this question
























      0












      0








      0








      Say I have this document



      userProfile: 
      createdAt: '2018-01-01',
      updatedAt: '2018-01-04'



      I want to retrieve all userProfiles that were updated after their creation, that means those that satisfy createdAt < updatedAt.

      Can you do that in Firestore?



      Something like this, but where the second operand is a field, not a value:



      userProfileRef.where("createdAt", "<", "updatedAt")


      Thanks










      share|improve this question














      Say I have this document



      userProfile: 
      createdAt: '2018-01-01',
      updatedAt: '2018-01-04'



      I want to retrieve all userProfiles that were updated after their creation, that means those that satisfy createdAt < updatedAt.

      Can you do that in Firestore?



      Something like this, but where the second operand is a field, not a value:



      userProfileRef.where("createdAt", "<", "updatedAt")


      Thanks







      firebase google-cloud-firestore






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 15:18









      r4id4r4id4

      2,36072955




      2,36072955






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You will not be able to do that with "standard" Firestore queries.



          The easiest way would be to either:



          1. Have a default "dummy" date (e.g. 1900-01-01) in the updatedAt field if the doc was never updated after creation. You would then query with userProfileRef.where("updatedAt", ">", "1900-01-01")

          or



          1. Have a specific flag in the document that you would update when you change the value of the updatedAt field (i.e. when you update the doc after creation).



          Note that you cannot query for documents that don't contain a given field (watch this official video for more details), therefore you cannot rely on the absence of the updatedAt field.






          share|improve this answer

























            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%2f55315225%2ffirestore-query-document-based-on-comparison-of-2-fields%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














            You will not be able to do that with "standard" Firestore queries.



            The easiest way would be to either:



            1. Have a default "dummy" date (e.g. 1900-01-01) in the updatedAt field if the doc was never updated after creation. You would then query with userProfileRef.where("updatedAt", ">", "1900-01-01")

            or



            1. Have a specific flag in the document that you would update when you change the value of the updatedAt field (i.e. when you update the doc after creation).



            Note that you cannot query for documents that don't contain a given field (watch this official video for more details), therefore you cannot rely on the absence of the updatedAt field.






            share|improve this answer





























              1














              You will not be able to do that with "standard" Firestore queries.



              The easiest way would be to either:



              1. Have a default "dummy" date (e.g. 1900-01-01) in the updatedAt field if the doc was never updated after creation. You would then query with userProfileRef.where("updatedAt", ">", "1900-01-01")

              or



              1. Have a specific flag in the document that you would update when you change the value of the updatedAt field (i.e. when you update the doc after creation).



              Note that you cannot query for documents that don't contain a given field (watch this official video for more details), therefore you cannot rely on the absence of the updatedAt field.






              share|improve this answer



























                1












                1








                1







                You will not be able to do that with "standard" Firestore queries.



                The easiest way would be to either:



                1. Have a default "dummy" date (e.g. 1900-01-01) in the updatedAt field if the doc was never updated after creation. You would then query with userProfileRef.where("updatedAt", ">", "1900-01-01")

                or



                1. Have a specific flag in the document that you would update when you change the value of the updatedAt field (i.e. when you update the doc after creation).



                Note that you cannot query for documents that don't contain a given field (watch this official video for more details), therefore you cannot rely on the absence of the updatedAt field.






                share|improve this answer















                You will not be able to do that with "standard" Firestore queries.



                The easiest way would be to either:



                1. Have a default "dummy" date (e.g. 1900-01-01) in the updatedAt field if the doc was never updated after creation. You would then query with userProfileRef.where("updatedAt", ">", "1900-01-01")

                or



                1. Have a specific flag in the document that you would update when you change the value of the updatedAt field (i.e. when you update the doc after creation).



                Note that you cannot query for documents that don't contain a given field (watch this official video for more details), therefore you cannot rely on the absence of the updatedAt field.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 23 at 16:59









                Frank van Puffelen

                252k31403431




                252k31403431










                answered Mar 23 at 15:28









                Renaud TarnecRenaud Tarnec

                15.2k21835




                15.2k21835





























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315225%2ffirestore-query-document-based-on-comparison-of-2-fields%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현