google-cloud-firestore

Query current user .once('value') in Firestore

淺唱寂寞╮ 提交于 2020-01-25 11:22:37
问题 I am transitioning a Firebase real-time database to a Firebase Firestore database but am having trouble finding the appropriate reference to query the current user. onAuthUserListener = (next, fallback) => this.auth.onAuthStateChanged(authUser => { if (authUser) { this.user(authUser.uid) .once('value') .then(snapshot => { const dbUser = snapshot.val(); // default empty roles if (!dbUser.roles) { dbUser.roles = []; } // merge auth and db user authUser = { uid: authUser.uid, email: authUser

How do I save user session using SharedPreferences in Cloud Firestore when I'm not using Firebase authentication?

守給你的承諾、 提交于 2020-01-25 10:21:13
问题 When a user registers in my Android app, their data is stored inside a collection, where the document ID is their email address which helps find a user. The password is stored inside the document as well. So when a user logins, their entered email is checked against a document ID matching that email, if it exists it will log in and display user control panel. Now after the login, I need to somehow create a user session, so that the user can never go back to the login screen until he logouts.

not able retrieve documents in chat application according to the timestamp

假如想象 提交于 2020-01-25 10:15:09
问题 I am using the below code to retrieve the messages in a chat application according to the timestamp but it is not retrieving in order of the timestamp, How should I make sure that messages retrieved are in the order of the timestamp. I am using Firestore database and Swift IOS for this application below is the code parts timestamp saved in database let timestamp = Int(NSDate().timeIntervalSince1970) Code to retrieve messages let ref = Firestore.firestore().collection("messages").order(by:

I want to write a rule that will don't allow add same document second time

早过忘川 提交于 2020-01-25 09:21:25
问题 rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /users/{usersID} { allow read; allow write: if request.auth.uid != null; match /desksCollection/{desksCollectionID} { allow read; allow write: if resource.data.DeskName != request.resource.data.DeskName; } } } } I want to write a rule that will don't allow add same document second time. What is incorrect here ? 回答1: What you are trying to do is not possible with security rules. This would require that

Waiting for observable to finish - Angular

送分小仙女□ 提交于 2020-01-25 08:28:05
问题 I'm using Angular and Firebase storage to upload images and I'm having the problem where my urlImg it's undefined when I try to print it in the console.log inside of the tap . this.snapshot = this.snapshot = this.task.snapshotChanges().pipe( finalize(() => { this.storage .ref(path) .getDownloadURL() .subscribe(url => { this.urlImg = url; // with this you can use it in the html }); }), tap(snap => { if (snap.bytesTransferred === snap.totalBytes) { // Update firestore on completion //Code to

Firestore in Datastore mode: index hotspots for enum property values vs. just poor indices?

自古美人都是妖i 提交于 2020-01-25 08:07:11
问题 I'm experiencing symptoms which suggest that Cloud Firestore in Datastore mode can be slow when querying for properties that are shared by many other entities. It seems this may be related to an inefficient index-less query (e.g. I need a composite index for this search), or an index hotspot (though I can only find documentation recommending against monotonically increasing values, not a small number of enum values). My situation (simplified) is as follows: I have 1M entities written to a

how to check favorite item document is exist from firestore

一曲冷凌霜 提交于 2020-01-25 07:32:05
问题 I need when user open the meal page see if that meal in favorite or not by making the favorite icon color to red but i can't check if the meal document is in firestore or not. I've tried to put this code in init state but it doesn't work i check icon color from isFavorite boolean. firestore .collection('favorites') .where('mealId', isEqualTo: widget.mealId) .where('userId', isEqualTo: userID) .getDocuments().then((f) { if(f.documents.isNotEmpty) { setState(() { isFavorite = true; }); } else {

firestore document id will be undefined after I update array

醉酒当歌 提交于 2020-01-25 07:29:53
问题 I have this flatlist wich recive data from firestore and send as props to projectsummery.js const ProjectList =({projects})=> { return( <FlatList data={projects} renderItem={(project,index)=>{ return( <ProjectSummery project={project} key={project.item.id} //keyExtractor={(item, index) =>item.id}/> ) } } /> ) } Here I have a button which which send document id which is something like this {project.item.id} == CSmet3tRjpjDcJ437M78 ProjectSummery.js const ProjectSummery =(props)=> { const

Listen For MetaData Changes in Firebase Firestore database

自作多情 提交于 2020-01-25 07:27:31
问题 I am creating a chat module using Firestore database. Following is my listener code that listen for new messages in: mDb.collection("Users_Collection").document(mAuth.getUid()).collection("Recipients") .document(psychichObj.getUid()).collection("Messages").orderBy("time").limit(30) .addSnapshotListener(MetadataChanges.INCLUDE, new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) { if (e==null

Stripe function cannot be found

佐手、 提交于 2020-01-25 07:24:48
问题 I am using Stripe in my angular7 application to handle payments via firebase cloud functions. I am currently trying to create a subscription payment. However, when I try and call the following function (as a sort of pre-req to the whole subscription setup); import * as Stripe from 'stripe'; const stripe = new Stripe('pk_test_....'); //Create payment method for customer const {paymentMethod, createPaymentMethodError} = await stripe.createPaymentMethod({ type: 'card', card: cardElementObj.card,