google-cloud-firestore

How to get server Timestamp from Firestore in an android device?

半世苍凉 提交于 2020-02-06 08:50:52
问题 This is related to this question: How can I get Timestamp from Firestore server without bothering for the case when device clock is out of sync with Firestore I have understood FieldValue.serverTimestamp() can be used to generate a Timestamp in Firestore server while performing database operations. I want to understand how I can get the timestamp from the Firestore Database in a particular device in a Date/Timestamp format without any database related operation. 回答1: So assuming you have a

How to get server Timestamp from Firestore in an android device?

时光毁灭记忆、已成空白 提交于 2020-02-06 08:48:07
问题 This is related to this question: How can I get Timestamp from Firestore server without bothering for the case when device clock is out of sync with Firestore I have understood FieldValue.serverTimestamp() can be used to generate a Timestamp in Firestore server while performing database operations. I want to understand how I can get the timestamp from the Firestore Database in a particular device in a Date/Timestamp format without any database related operation. 回答1: So assuming you have a

In swift, how to make function to return querysnapshot from Firebase?

可紊 提交于 2020-02-06 06:41:06
问题 In swift, how can I return a the querySnapshot in this code: func read(){ reference(to: .users).getDocuments() { (querySnapshot, err) in if let err = err { print("Error getting documents: \(err)") } else { for document in querySnapshot!.documents { print("\(document.documentID) => \(document.data())") } } } } The above code reads the data from firebase and prints the data out in the else statement. I want to call the read() function from a view controller and read() should return the

In swift, how to make function to return querysnapshot from Firebase?

雨燕双飞 提交于 2020-02-06 06:36:09
问题 In swift, how can I return a the querySnapshot in this code: func read(){ reference(to: .users).getDocuments() { (querySnapshot, err) in if let err = err { print("Error getting documents: \(err)") } else { for document in querySnapshot!.documents { print("\(document.documentID) => \(document.data())") } } } } The above code reads the data from firebase and prints the data out in the else statement. I want to call the read() function from a view controller and read() should return the

auto generate id for document and not collection in firestore

喜夏-厌秋 提交于 2020-02-05 05:17:08
问题 I have gone through the firestore docs and I'm yet to find an example where we have something like this. collection |--document |--{auto-generated-id} |--property1:value1 |--property2:value2 |--peoperty3:value3 Rather what I often see is: collection |--{auto-generated-id} |--property1:value1 |--property2:value2 |--peoperty3:value3 In the former, I cannot call add() -(which generates unique id) on a document. However this can be done in a collection as shown in the latter sketch above. My

Firebase Timestamp difference between current Timestamp and database timestamp error

◇◆丶佛笑我妖孽 提交于 2020-02-05 04:25:08
问题 I have written a TimeValidityCheckUtil which determines if the snapshot from a particular listener is within a given time-frame of the current time of the device. This has this method, checkIfTImeValid public static boolean checkIfTimeValid(Timestamp dbTimestamp) { Timestamp currentTimestamp = Timestamp.now(); Long seconds = currentTimestamp.getSeconds() - dbTimestamp.getSeconds(); if(seconds> 10) { return false; } return true; } The database structure is in Firestore and is as follows: "ABC"

React useEffect hook load onsnapshot conditionally

穿精又带淫゛_ 提交于 2020-02-04 09:29:28
问题 I am trying to do the following and cannot seem to get the most suitable solution: On the top level of my React app (App component) I am loading firebase and firestore. I have a react context where my auth info is stored in. The auth context is not immediately loaded but after some time. I am using the onAuthStateChanged (from firebase) to wait for it. My code looks as follows: const firebase = new Firebase(); //custom class, instantiates firebase const [authData, setAuthData] = useState({

firebase/firestore: create and store unique id for documents (users for USERID)

☆樱花仙子☆ 提交于 2020-02-04 01:33:08
问题 I would like to generate unique ID for each user based on the location. eg: if the user is from newyouk, ID would be NY-23234. This should happen the very first time when the user sign up to my app. I see that I could use auto generated firestore ID - but it is too long for assigning as id and it can't have any other characters with it. I am using angularfire2 to connect to firestore. What I am thinking now is : every time a new user is signed up, save the user details in 'users collection'

Firebase Collection Group Query on Id / Key

不想你离开。 提交于 2020-02-03 13:57:28
问题 I have been following along the following document: https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query My data structure roughly looks like this: /teams/{teamid} { displayName: "Company X Team", owner: "userid", } /teams/{teamid}/invites/{emailAddressAsKey} { someProp: "my data" } In my web app I want to search through all the different teams records to find an invite who's id/key is equal to the email address that I pass in. After reading through the

Firebase Collection Group Query on Id / Key

◇◆丶佛笑我妖孽 提交于 2020-02-03 13:55:48
问题 I have been following along the following document: https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query My data structure roughly looks like this: /teams/{teamid} { displayName: "Company X Team", owner: "userid", } /teams/{teamid}/invites/{emailAddressAsKey} { someProp: "my data" } In my web app I want to search through all the different teams records to find an invite who's id/key is equal to the email address that I pass in. After reading through the