Query Firestore to get documents in a range of documentIDs [duplicate]









up vote
0
down vote

favorite













This question already has an answer here:



  • Google Firestore - how to get document by multiple ids in one round trip?

    7 answers



I'm developing a Flutter app using Firebase and Cloud Firestore.



In Firestore I have a collections of Users.



I want to perform a query who give me a list of Users with documentId in a range.



Example



My database:



> Users --> docId1 --> name: "Domenico"
> --> docId2 --> name: "Antonio"
> --> docId3 --> name: "Maria"


My desidered query is something like:



Select name from Users
where documentId in (docId2, docId3)


who gives me ["Antonio", "Maria"].



On documentation I've found how to filter by a document key but not a collection by a range of ducumentId.



Can you help me to perform this query or to understand if I'm doing something wrong?



Thank you.










share|improve this question















marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 11 at 15:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    There is indeed no way to build such a query to Firestore. In Javascript you would use Promise.all() to execute several asynchronous queries in parallel. I don't know how to do that in Dart, however.
    – Renaud Tarnec
    Nov 11 at 10:37











  • PS: this may help stackoverflow.com/questions/42176092/…
    – Renaud Tarnec
    Nov 11 at 10:39










  • Maybe you can save the document id (also) as a field in the document and perform a range query on this field
    – vinsce
    Nov 12 at 10:44














up vote
0
down vote

favorite













This question already has an answer here:



  • Google Firestore - how to get document by multiple ids in one round trip?

    7 answers



I'm developing a Flutter app using Firebase and Cloud Firestore.



In Firestore I have a collections of Users.



I want to perform a query who give me a list of Users with documentId in a range.



Example



My database:



> Users --> docId1 --> name: "Domenico"
> --> docId2 --> name: "Antonio"
> --> docId3 --> name: "Maria"


My desidered query is something like:



Select name from Users
where documentId in (docId2, docId3)


who gives me ["Antonio", "Maria"].



On documentation I've found how to filter by a document key but not a collection by a range of ducumentId.



Can you help me to perform this query or to understand if I'm doing something wrong?



Thank you.










share|improve this question















marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 11 at 15:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    There is indeed no way to build such a query to Firestore. In Javascript you would use Promise.all() to execute several asynchronous queries in parallel. I don't know how to do that in Dart, however.
    – Renaud Tarnec
    Nov 11 at 10:37











  • PS: this may help stackoverflow.com/questions/42176092/…
    – Renaud Tarnec
    Nov 11 at 10:39










  • Maybe you can save the document id (also) as a field in the document and perform a range query on this field
    – vinsce
    Nov 12 at 10:44












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • Google Firestore - how to get document by multiple ids in one round trip?

    7 answers



I'm developing a Flutter app using Firebase and Cloud Firestore.



In Firestore I have a collections of Users.



I want to perform a query who give me a list of Users with documentId in a range.



Example



My database:



> Users --> docId1 --> name: "Domenico"
> --> docId2 --> name: "Antonio"
> --> docId3 --> name: "Maria"


My desidered query is something like:



Select name from Users
where documentId in (docId2, docId3)


who gives me ["Antonio", "Maria"].



On documentation I've found how to filter by a document key but not a collection by a range of ducumentId.



Can you help me to perform this query or to understand if I'm doing something wrong?



Thank you.










share|improve this question
















This question already has an answer here:



  • Google Firestore - how to get document by multiple ids in one round trip?

    7 answers



I'm developing a Flutter app using Firebase and Cloud Firestore.



In Firestore I have a collections of Users.



I want to perform a query who give me a list of Users with documentId in a range.



Example



My database:



> Users --> docId1 --> name: "Domenico"
> --> docId2 --> name: "Antonio"
> --> docId3 --> name: "Maria"


My desidered query is something like:



Select name from Users
where documentId in (docId2, docId3)


who gives me ["Antonio", "Maria"].



On documentation I've found how to filter by a document key but not a collection by a range of ducumentId.



Can you help me to perform this query or to understand if I'm doing something wrong?



Thank you.





This question already has an answer here:



  • Google Firestore - how to get document by multiple ids in one round trip?

    7 answers







firebase flutter google-cloud-firestore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 10:02

























asked Nov 11 at 9:55









ilBarra

386




386




marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 11 at 15:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 11 at 15:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2




    There is indeed no way to build such a query to Firestore. In Javascript you would use Promise.all() to execute several asynchronous queries in parallel. I don't know how to do that in Dart, however.
    – Renaud Tarnec
    Nov 11 at 10:37











  • PS: this may help stackoverflow.com/questions/42176092/…
    – Renaud Tarnec
    Nov 11 at 10:39










  • Maybe you can save the document id (also) as a field in the document and perform a range query on this field
    – vinsce
    Nov 12 at 10:44












  • 2




    There is indeed no way to build such a query to Firestore. In Javascript you would use Promise.all() to execute several asynchronous queries in parallel. I don't know how to do that in Dart, however.
    – Renaud Tarnec
    Nov 11 at 10:37











  • PS: this may help stackoverflow.com/questions/42176092/…
    – Renaud Tarnec
    Nov 11 at 10:39










  • Maybe you can save the document id (also) as a field in the document and perform a range query on this field
    – vinsce
    Nov 12 at 10:44







2




2




There is indeed no way to build such a query to Firestore. In Javascript you would use Promise.all() to execute several asynchronous queries in parallel. I don't know how to do that in Dart, however.
– Renaud Tarnec
Nov 11 at 10:37





There is indeed no way to build such a query to Firestore. In Javascript you would use Promise.all() to execute several asynchronous queries in parallel. I don't know how to do that in Dart, however.
– Renaud Tarnec
Nov 11 at 10:37













PS: this may help stackoverflow.com/questions/42176092/…
– Renaud Tarnec
Nov 11 at 10:39




PS: this may help stackoverflow.com/questions/42176092/…
– Renaud Tarnec
Nov 11 at 10:39












Maybe you can save the document id (also) as a field in the document and perform a range query on this field
– vinsce
Nov 12 at 10:44




Maybe you can save the document id (also) as a field in the document and perform a range query on this field
– vinsce
Nov 12 at 10:44












1 Answer
1






active

oldest

votes

















up vote
1
down vote













You can't query on a range of id.
You have to do Two distinct query



var query = firestore.collection("users").doc(docId);


But if you just want to filter on user Name you can do this



var query = firestore.collection("users").where('name', isEqualTo: 'Domenico');


This kind of query is one of the disadvantage of using firestore.






share|improve this answer



























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    You can't query on a range of id.
    You have to do Two distinct query



    var query = firestore.collection("users").doc(docId);


    But if you just want to filter on user Name you can do this



    var query = firestore.collection("users").where('name', isEqualTo: 'Domenico');


    This kind of query is one of the disadvantage of using firestore.






    share|improve this answer
























      up vote
      1
      down vote













      You can't query on a range of id.
      You have to do Two distinct query



      var query = firestore.collection("users").doc(docId);


      But if you just want to filter on user Name you can do this



      var query = firestore.collection("users").where('name', isEqualTo: 'Domenico');


      This kind of query is one of the disadvantage of using firestore.






      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        You can't query on a range of id.
        You have to do Two distinct query



        var query = firestore.collection("users").doc(docId);


        But if you just want to filter on user Name you can do this



        var query = firestore.collection("users").where('name', isEqualTo: 'Domenico');


        This kind of query is one of the disadvantage of using firestore.






        share|improve this answer












        You can't query on a range of id.
        You have to do Two distinct query



        var query = firestore.collection("users").doc(docId);


        But if you just want to filter on user Name you can do this



        var query = firestore.collection("users").where('name', isEqualTo: 'Domenico');


        This kind of query is one of the disadvantage of using firestore.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 11:44









        mcfly

        298211




        298211













            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto