Cloud Firestore and Ionic










0















How can I get the document id of a collection present in the cloud Firestore?



I tried to get it by using the



firebase.firestore().collection("collectionName").doc().id


but I didn't get the appropriate result.










share|improve this question
























  • What are you trying to execute? get all ids? or get specific id? or get a reference id for future addition of document?

    – Socrates Tuas
    Nov 12 '18 at 14:14











  • What is the result that you get? Please reponde with @

    – Alex Mamo
    Nov 12 '18 at 15:45











  • I am trying to get a specific id.

    – Saurabh kumar
    Nov 13 '18 at 6:34











  • It returns an ID which is not related to any of the document available in my collection @AlexMamo

    – Saurabh kumar
    Nov 13 '18 at 9:42











  • @Saurabhkumar Which looks like?

    – Alex Mamo
    Nov 13 '18 at 9:43















0















How can I get the document id of a collection present in the cloud Firestore?



I tried to get it by using the



firebase.firestore().collection("collectionName").doc().id


but I didn't get the appropriate result.










share|improve this question
























  • What are you trying to execute? get all ids? or get specific id? or get a reference id for future addition of document?

    – Socrates Tuas
    Nov 12 '18 at 14:14











  • What is the result that you get? Please reponde with @

    – Alex Mamo
    Nov 12 '18 at 15:45











  • I am trying to get a specific id.

    – Saurabh kumar
    Nov 13 '18 at 6:34











  • It returns an ID which is not related to any of the document available in my collection @AlexMamo

    – Saurabh kumar
    Nov 13 '18 at 9:42











  • @Saurabhkumar Which looks like?

    – Alex Mamo
    Nov 13 '18 at 9:43













0












0








0








How can I get the document id of a collection present in the cloud Firestore?



I tried to get it by using the



firebase.firestore().collection("collectionName").doc().id


but I didn't get the appropriate result.










share|improve this question
















How can I get the document id of a collection present in the cloud Firestore?



I tried to get it by using the



firebase.firestore().collection("collectionName").doc().id


but I didn't get the appropriate result.







ionic-framework google-cloud-firestore cloud






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 13:08









Greenonline

1,01421524




1,01421524










asked Nov 12 '18 at 12:59









Saurabh kumarSaurabh kumar

33




33












  • What are you trying to execute? get all ids? or get specific id? or get a reference id for future addition of document?

    – Socrates Tuas
    Nov 12 '18 at 14:14











  • What is the result that you get? Please reponde with @

    – Alex Mamo
    Nov 12 '18 at 15:45











  • I am trying to get a specific id.

    – Saurabh kumar
    Nov 13 '18 at 6:34











  • It returns an ID which is not related to any of the document available in my collection @AlexMamo

    – Saurabh kumar
    Nov 13 '18 at 9:42











  • @Saurabhkumar Which looks like?

    – Alex Mamo
    Nov 13 '18 at 9:43

















  • What are you trying to execute? get all ids? or get specific id? or get a reference id for future addition of document?

    – Socrates Tuas
    Nov 12 '18 at 14:14











  • What is the result that you get? Please reponde with @

    – Alex Mamo
    Nov 12 '18 at 15:45











  • I am trying to get a specific id.

    – Saurabh kumar
    Nov 13 '18 at 6:34











  • It returns an ID which is not related to any of the document available in my collection @AlexMamo

    – Saurabh kumar
    Nov 13 '18 at 9:42











  • @Saurabhkumar Which looks like?

    – Alex Mamo
    Nov 13 '18 at 9:43
















What are you trying to execute? get all ids? or get specific id? or get a reference id for future addition of document?

– Socrates Tuas
Nov 12 '18 at 14:14





What are you trying to execute? get all ids? or get specific id? or get a reference id for future addition of document?

– Socrates Tuas
Nov 12 '18 at 14:14













What is the result that you get? Please reponde with @

– Alex Mamo
Nov 12 '18 at 15:45





What is the result that you get? Please reponde with @

– Alex Mamo
Nov 12 '18 at 15:45













I am trying to get a specific id.

– Saurabh kumar
Nov 13 '18 at 6:34





I am trying to get a specific id.

– Saurabh kumar
Nov 13 '18 at 6:34













It returns an ID which is not related to any of the document available in my collection @AlexMamo

– Saurabh kumar
Nov 13 '18 at 9:42





It returns an ID which is not related to any of the document available in my collection @AlexMamo

– Saurabh kumar
Nov 13 '18 at 9:42













@Saurabhkumar Which looks like?

– Alex Mamo
Nov 13 '18 at 9:43





@Saurabhkumar Which looks like?

– Alex Mamo
Nov 13 '18 at 9:43












1 Answer
1






active

oldest

votes


















0















firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId




That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.



In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:



firebase.firestore().collection("societies").doc(this.myId)





share|improve this answer

























  • Hi Saurabh! Have you tried my solution above, does it work?

    – Alex Mamo
    Nov 14 '18 at 8: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%2f53262704%2fcloud-firestore-and-ionic%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









0















firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId




That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.



In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:



firebase.firestore().collection("societies").doc(this.myId)





share|improve this answer

























  • Hi Saurabh! Have you tried my solution above, does it work?

    – Alex Mamo
    Nov 14 '18 at 8:44















0















firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId




That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.



In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:



firebase.firestore().collection("societies").doc(this.myId)





share|improve this answer

























  • Hi Saurabh! Have you tried my solution above, does it work?

    – Alex Mamo
    Nov 14 '18 at 8:44













0












0








0








firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId




That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.



In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:



firebase.firestore().collection("societies").doc(this.myId)





share|improve this answer
















firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId




That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.



In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:



firebase.firestore().collection("societies").doc(this.myId)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 13:15

























answered Nov 13 '18 at 10:19









Alex MamoAlex Mamo

42.4k82860




42.4k82860












  • Hi Saurabh! Have you tried my solution above, does it work?

    – Alex Mamo
    Nov 14 '18 at 8:44

















  • Hi Saurabh! Have you tried my solution above, does it work?

    – Alex Mamo
    Nov 14 '18 at 8:44
















Hi Saurabh! Have you tried my solution above, does it work?

– Alex Mamo
Nov 14 '18 at 8:44





Hi Saurabh! Have you tried my solution above, does it work?

– Alex Mamo
Nov 14 '18 at 8: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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262704%2fcloud-firestore-and-ionic%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

27

Top Tejano songwriter Luis Silva dead of heart attack at 64

Category:Rhetoric