admin管理员组文章数量:1333396
i had an issue where i would like to generate the unique id without sending any data. Below is my code of getting the id, but i would like to get it before i could send the actual data to the database
var getUniqueId = firetoreDB.collection("collction").add({
data: "data"
}).then(function (doc) {
console.log(doc.id);
}).catch(function (error) {
console.log(error);
});
The above code gets me the id but i wanted to get it without out sending a test data to the database
i had an issue where i would like to generate the unique id without sending any data. Below is my code of getting the id, but i would like to get it before i could send the actual data to the database
var getUniqueId = firetoreDB.collection("collction").add({
data: "data"
}).then(function (doc) {
console.log(doc.id);
}).catch(function (error) {
console.log(error);
});
The above code gets me the id but i wanted to get it without out sending a test data to the database
Share Improve this question asked Mar 24, 2018 at 8:50 Jama MohamedJama Mohamed 3,4154 gold badges31 silver badges50 bronze badges 1-
1
You can use
firetoreDB.collection("collection").doc()
to to create a document with an auto-generated ID – Alexander Commented Mar 24, 2018 at 9:00
1 Answer
Reset to default 7Try this
firetoreDB.collection("collection").doc().id
本文标签: javascriptHow to get firebase firestore generated idStack Overflow
版权声明:本文标题:javascript - How to get firebase firestore generated id - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742335100a2455467.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论