Cloud Firestore and Ionic
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
|
show 3 more comments
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
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
|
show 3 more comments
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
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
ionic-framework google-cloud-firestore cloud
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
|
show 3 more comments
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
|
show 3 more comments
1 Answer
1
active
oldest
votes
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)
Hi Saurabh! Have you tried my solution above, does it work?
– Alex Mamo
Nov 14 '18 at 8:44
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%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
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)
Hi Saurabh! Have you tried my solution above, does it work?
– Alex Mamo
Nov 14 '18 at 8:44
add a comment |
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)
Hi Saurabh! Have you tried my solution above, does it work?
– Alex Mamo
Nov 14 '18 at 8:44
add a comment |
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)
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)
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
add a comment |
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
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%2f53262704%2fcloud-firestore-and-ionic%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
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