google-cloud-firestore

Adding time to Firestore serverTimestamp()

微笑、不失礼 提交于 2020-01-30 06:59:47
问题 Is there a way to add time to a server timestamp without using cloud functions? What I want is to update a timestamp from a panel, and have the user side check if the timestamp is greater than the current time. I also would like for the panel user to be able to set the amount of time to add, so doing the logic on the user side is not an optimal solution. Example: document.set({ validTo: firestore.FieldValue.serverTimestamp() + 5000 }); 回答1: You can't perform date math on server timestamps on

Adding time to Firestore serverTimestamp()

只愿长相守 提交于 2020-01-30 06:58:07
问题 Is there a way to add time to a server timestamp without using cloud functions? What I want is to update a timestamp from a panel, and have the user side check if the timestamp is greater than the current time. I also would like for the panel user to be able to set the amount of time to add, so doing the logic on the user side is not an optimal solution. Example: document.set({ validTo: firestore.FieldValue.serverTimestamp() + 5000 }); 回答1: You can't perform date math on server timestamps on

Firebase - firestore createdAt timestamps - react

六眼飞鱼酱① 提交于 2020-01-30 06:25:45
问题 I am trying to figure out how to add timestamps to documents created in my firestore database. I have read and tried each and every one of the suggestions in this post. I have read the documentation links on that post and I can't make sense of the steps I'm supposed to try to implement in order to record the timestamp for the document creation date. In my firebase settings I have: firebase.initializeApp(config); const database = firebase.database(); const fsDB = firebase.firestore(); const

Firebase - firestore createdAt timestamps - react

核能气质少年 提交于 2020-01-30 06:25:05
问题 I am trying to figure out how to add timestamps to documents created in my firestore database. I have read and tried each and every one of the suggestions in this post. I have read the documentation links on that post and I can't make sense of the steps I'm supposed to try to implement in order to record the timestamp for the document creation date. In my firebase settings I have: firebase.initializeApp(config); const database = firebase.database(); const fsDB = firebase.firestore(); const

I am unable to write data to Firebase Firestore

心已入冬 提交于 2020-01-29 20:08:52
问题 Any suggestions about why it is happening. I have used in the below mentioned manner: FirebaseFirestore dbFirestore; dbFirestore = FirebaseFirestore.getInstance(); While Uploading I have used it in this manner: documentReference= dbFirestore.collection("CLIENT_DETAIL").document(mAuth.getUid()); documentReference.set(userData); I am not able to write it on Firestore, I tried many different possibilities. However, sometimes it does write when I try to log in but not when the code execute while

I am unable to write data to Firebase Firestore

女生的网名这么多〃 提交于 2020-01-29 20:08:20
问题 Any suggestions about why it is happening. I have used in the below mentioned manner: FirebaseFirestore dbFirestore; dbFirestore = FirebaseFirestore.getInstance(); While Uploading I have used it in this manner: documentReference= dbFirestore.collection("CLIENT_DETAIL").document(mAuth.getUid()); documentReference.set(userData); I am not able to write it on Firestore, I tried many different possibilities. However, sometimes it does write when I try to log in but not when the code execute while

Firebase cannot retrieve data from database “db.collection is not a function”

こ雲淡風輕ζ 提交于 2020-01-29 17:52:46
问题 Cannot get anything from the firebase database. It is showing an error of: Uncaught TypeError: db.collection is not a function I have the script setup here as shown: var config = { apiKey: "*****", authDomain: "*****", databaseURL: "*****", projectId: "*****", storageBucket: "*****", messagingSenderId: "*****" }; firebase.initializeApp(config); const db = firebase.database(); const firstName = document.querySelector('#firstName').value; const mainButton = document.querySelector('#mainButton')

Firebase cannot retrieve data from database “db.collection is not a function”

和自甴很熟 提交于 2020-01-29 17:52:09
问题 Cannot get anything from the firebase database. It is showing an error of: Uncaught TypeError: db.collection is not a function I have the script setup here as shown: var config = { apiKey: "*****", authDomain: "*****", databaseURL: "*****", projectId: "*****", storageBucket: "*****", messagingSenderId: "*****" }; firebase.initializeApp(config); const db = firebase.database(); const firstName = document.querySelector('#firstName').value; const mainButton = document.querySelector('#mainButton')

Firestore pagination - Is there any query compatible with firebase's limitToLast?

大憨熊 提交于 2020-01-29 17:46:48
问题 Is there a way to implement back pagination with firestore? I am struggling to implement pagination with firestore, and there are limited firestore queries for it. Forward pagination can be made by startAt and limit method, that is ok. But back pagination can't be easily done, because we only have endBefore , and endAt method, and how can we get last n elements from given document? I know realtime database have method limitToLast . Is there any query like this for firestore? (Also I need to

How to resolve/return a forEach function in Cloud Functions

孤街浪徒 提交于 2020-01-25 23:01:28
问题 I have the following (sample) array: pages = [ { "name" : "Hello", "id" : 123 },{ "name" : "There", "id" : 987 },{ "name" : "Great", "id" : 555 } ]; I want to save every object in this array as Document in a Collection. Therefor I have the following function: exports.testSaveFacebookPages = functions.https.onRequest((req, res) => { cors(req, res, () => { let userUid = req.body.uid // pages array is available here... const PagesRef = admin.firestore().collection(`/users/${userUid}/pages/`)