google-cloud-firestore

Firebase querying by date not working after deploy

两盒软妹~` 提交于 2020-07-08 03:24:17
问题 I'm working on a REST API with firebase and I'm querying some data by date. It works fine on the localhost but after deploy, it does not! I'm also using momentjs to help to deal with dates. The date field of my document is a timestamp. Here is how I'm doing my query: const documents = await admin.firestore() .collection('orders') .where('date', '>', moment('2020-06-23')) .where('date', '<', moment('2020-06-24')) .get() I have also done the same thing with Date() instead of momentjs const

Firestore: Update fields in nested objects

余生长醉 提交于 2020-07-07 06:05:38
问题 How can one update fields in a document's nested object? The documentation indicated dot notation but how do you achieve the update with a variable as the object name? Structure is like: collection("fruits").doc("as867f56asd") name: "banana" abc-variable: description:"blah" qty: 1 I want to update document as867f56asd 's abc-variable.qty = 2 My JavaScript requires the use of a variable for the object name. I can't figure out bracket notation for the update. Is .set{merge:true} req'd? Here is

Fetching data from Firestore

纵饮孤独 提交于 2020-07-07 05:51:47
问题 So I am trying to fetch data from Firestore, when I console log it I got the content of my collection back, but when I move the code to a function I am not able to return it back. This code works: const db = firebase.firestore(); db.settings({ timestampsInSnapshots: true}); db.collection('story').get().then((snapshot) => { snapshot.docs.forEach(doc => {console.log(doc.data()) ;}) }) This doesnt work. (it compiles, but doesn`t return anything): ... getMyStory = () => { const db = firebase

Flutter Firestore where clause using map

社会主义新天地 提交于 2020-07-06 12:48:26
问题 When a new activity is posted i add a new post document into the collection. Inside this document i have a map where users add confirmation to the event marking it as true and adding his own id. var snap = await Firestore.instance .collection('user_posts') .where("confirmations.${user.id}",isEqualTo: true) .getDocuments(); With this snippet i'm able to get all the posts confirmed by the user. The issue here is to get this a index is required to perform this query. And this index can't be

What's the best way to model Custom Object for Document ID in Firestore?

て烟熏妆下的殇ゞ 提交于 2020-07-06 10:25:30
问题 Say I have a collection of 'Users', and am happy for their ID to be the generated Firestore documentId, something like: Users Collection GENERATED_FIRESTORE_ID1: name: "User 1 name" ...: etc. GENERATED_FIRESTORE_ID2: name: "User 2 name" ...: etc." and I am adding them, and retrieving them with a custom object (I'm using Android at the moment but the question I guess is more generalistic). I don't want to have an extra "id" field in the document, just use the document.getId() method to get the

How to use kotlin coroutines in firebase database

青春壹個敷衍的年華 提交于 2020-07-05 07:32:06
问题 I'm trying to access chatting room Using firestore and coroutines. fun getOwner() { runBlocking { var de = async(Dispatchers.IO) { firestore.collection("Chat").document("cF7DrENgQ4noWjr3SxKX").get() } var result = de.await().result } But i get error like this : E/AndroidRuntime: FATAL EXCEPTION: Timer-0 Process: com.example.map_fetchuser_trest, PID: 19329 java.lang.IllegalStateException: Task is not yet complete at com.google.android.gms.common.internal.Preconditions.checkState(Unknown Source

Update a field in an object in Firestore?

早过忘川 提交于 2020-07-05 05:55:34
问题 This is the example provided in the documentation to update a field within a nested object in firebase. var frankDocRef = db.collection("users").doc("frank"); frankDocRef.set({ name: "Frank", favorites: { food: "Pizza", color: "Blue", subject: "recess" }, age: 12 }); // To update age and favorite color: db.collection("users").doc("frank").update({ "age": 13, "favorites.color": "Red" }) .then(function() { console.log("Document successfully updated!"); }); Instead of updating the favourites, I

Secure Firestore database using rules. Check authentication. Is it enough?

久未见 提交于 2020-07-05 04:59:46
问题 I'm new to Firebase and trying to understand database rules. I'm using Firestore. I have a database that basically needs to be read by all users, and also write. All users can see the documents in the database, and with certain actions they change certain fields. In certain cases they will detele certain old expired documents. Now, I understand that I cannot leave read and write open to all, since this is not secure. So I am using authentication, I will anonymously authenticate the users, so

How to paginate to previous page using AngularFire, Firestore and Firebase

大憨熊 提交于 2020-07-04 09:46:53
问题 Sorry I have seen this question has been asked many times in different ways here such as: Howto paginate back to previous pages in a Angular(6) and firebase Firestore setup How to paginate Firestore dataset by individual page? But NONE of the answers really explain the solution or are understandable. Also I went though many tutorials such as: https://howtofirebase.com/firebase-data-structures-pagination-96c16ffdb5ca https://rexrainbow.github.io/phaser3-rex-notes/docs/site/firebase-firestore/

How to query firestore document inside streambuilder and update the listview

吃可爱长大的小学妹 提交于 2020-07-04 08:11:27
问题 I'm trying to retrieve posts from a Firestore collection called "posts", which contains the post creator's userID and post description and this is possible by using both StreamBuilder and FutureBuilder(Not preferable, because it gets a snapshot only once and doesn't update when a field changes). However, I want to query another collection called "users" with the post creator's userID and retrieve the document that matches the userId. This was my first approach: StreamBuilder<QuerySnapshot>(