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;
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
add a comment |
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
add a comment |
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
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
firebase google-cloud-firestore
asked Mar 23 at 15:18
r4id4r4id4
2,36072955
2,36072955
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You will not be able to do that with "standard" Firestore queries.
The easiest way would be to either:
- 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 withuserProfileRef.where("updatedAt", ">", "1900-01-01")
or
- 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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You will not be able to do that with "standard" Firestore queries.
The easiest way would be to either:
- 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 withuserProfileRef.where("updatedAt", ">", "1900-01-01")
or
- 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.
add a comment |
You will not be able to do that with "standard" Firestore queries.
The easiest way would be to either:
- 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 withuserProfileRef.where("updatedAt", ">", "1900-01-01")
or
- 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.
add a comment |
You will not be able to do that with "standard" Firestore queries.
The easiest way would be to either:
- 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 withuserProfileRef.where("updatedAt", ">", "1900-01-01")
or
- 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.
You will not be able to do that with "standard" Firestore queries.
The easiest way would be to either:
- 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 withuserProfileRef.where("updatedAt", ">", "1900-01-01")
or
- 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.
edited Mar 23 at 16:59
Frank van Puffelen
252k31403431
252k31403431
answered Mar 23 at 15:28
Renaud TarnecRenaud Tarnec
15.2k21835
15.2k21835
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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