Posts

Showing posts with the label google-cloud-firestore

Get single record from Firestore using Vue.js

Image
Clash Royale CLAN TAG #URR8PPP Get single record from Firestore using Vue.js I am trying to get a single record from a Firestore db where I am pulling the ID from the path but it doesn't seem to be working. When I console log I get nothing at all in the log so not sure why the created code doesn't seem to be running Can you see what I am doing wrong please // Import firestorm Database import db from '~/services/fireinit.js' export default { data() { return { post: } }, created() { let ref = db.collection('post').doc(this.$route.params.id) ref.get() .then(snapshot => { snapshot.forEach(doc => { let post = doc.data() console.log(post) }) }) } I should add that get all works fine db.collection('post').get() my console.log returns nothing even if I add a string to it so it doesn't appear this block of code is running, but I have no errors at all in the console. ...

Firestore collection's document amount

Image
Clash Royale CLAN TAG #URR8PPP Firestore collection's document amount I'm starting to use firestore database as my database and I have wondered if there is any limit to the amount of documents I have in a collection. Thansk By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

how to assign the result of snapshot in a variable in firestore angularfire

how to assign the result of snapshot in a variable in firestore angularfire I just want to check if the email exists then I will get the rest of the doc but I can't seem to assign the result in variable. this.db.collection('accounts', ref => ref .where('inviteCode', '==', 'abcd1234') .get() .then(querySnapshot => { const results = ; querySnapshot.forEach(doc => { results.push(doc.data()); }); this.myArray = results; // this is my variable }) .catch(function (error) { console.log('Error getting documents', error); })); I tried using Promise.all(results) but it seems i'm not doing it right. UPDATE: export class FirebaseService { preloginRef: AngularFirestoreCollection<PreLogin>; myArray: ; constructor(private db: AngularFirestore) { this.preloginRef = db.collection(this.dbPath); } codeCheck(inviteCode: string) { this.db.collection('accounts', ref => ref .where(...