google-cloud-firestore

add a property to a created object (Firebase Functions)

北城余情 提交于 2021-01-29 09:19:36
问题 I'm hooking to the creation of objects on a specific collection (orders) I need to add a new property to the object before it's saved, not returning anything, to no avail. I have looked at the documentation at https://firebase.google.com/docs/reference/functions/functions.firestore.DocumentBuilder#writing_data but it's for onUpdate so it doesn't work as i intend it. exports.createOrder = firestore.document('orders/{orderId}').onCreate((snap, context) => { const newOrder = snap.data() console

Firestore - query all documents which field matches values in a list (like SQL IN)

荒凉一梦 提交于 2021-01-29 08:46:01
问题 I have a book collection for example, each book has 'genre' field. How to query all books which genre is "fantasy" or "historical"? Like SQL SELECT * FROM book WHERE genre in ("fantasy", "historical") . Pretty usual SQL query as my opinion. I found this feature request in GitHub, which isn't resolved yet. The Firestore documentation says: "Logical OR queries aren't supported". So, I cannot do such simple query in Firestore? What is a workaround? Should I query each genre separately and join

Get field from Firestore document

我与影子孤独终老i 提交于 2021-01-29 08:26:06
问题 Is it possible to extract and parse just a single field from a Firestore object without running a For Each or alternatively first passing this to an array? Specifically, I have pulled a single document as below (below working): const docRef = admin .firestore() .collection("profiles") .doc(profileId); From this I would like to parse a single field (accountBalance) but not able to do this (assumed to work but does not): const accountBalance = docRef.accountBalance; Does this need to be parsed?

Firebase - Cloud Functions - make queries on collection

纵然是瞬间 提交于 2021-01-29 08:17:29
问题 Lets say I have two top level collection with users and stories. Now everytime a document from user gets update (only the values username or photoUrl ), I want to update these properties on a document from the story collection. One users doc could look like this (shortened): { username: 'blubber', photoUrl: 'my/photo/path', uid: 'usersUniqueId' } The story doc could look like this (shortened): { username: 'blubber', photoUrl: 'my/photo/path', uid: 'usersUniqueId', sid: 'storiesUniqueId,

Firebase Realtime Database to Cloud Firestore

≡放荡痞女 提交于 2021-01-29 08:12:00
问题 I´m searching the best way to migrate Firebase Realtime Database Data to Cloud Firestore for a json database with many nested rows. Example: I found nothing that could help me. For what I need the migration is the new offline functionality of the Cloud Firestore. I´m using Ionic3 (Angular5) 回答1: Actually there's no standard way to migrate from Firebase Realtime Database to Cloud Firestore, because every application or project has is unique. You have to implement your own way of migrating to

Flutter - PlatformException : error, Invalid document reference. Document references must have an even number of segments, but users has 1, null

旧巷老猫 提交于 2021-01-29 08:06:55
问题 I wanted to get my users data from cloud firestore. It worked first but now it is raising a error. "PlatformException (PlatformException(error, Invalid document reference. Document references must have an even number of segments, but users has 1, null))" String name = "", email = "", pnumber = "", imgUrl = "", bio = "", posted = "", applied = "", rating = "", saved = ""; String url; final formKey = new GlobalKey<FormState>(); final databaseReference = Firestore.instance; String uID; @override

Flutter - PlatformException : error, Invalid document reference. Document references must have an even number of segments, but users has 1, null

☆樱花仙子☆ 提交于 2021-01-29 08:06:46
问题 I wanted to get my users data from cloud firestore. It worked first but now it is raising a error. "PlatformException (PlatformException(error, Invalid document reference. Document references must have an even number of segments, but users has 1, null))" String name = "", email = "", pnumber = "", imgUrl = "", bio = "", posted = "", applied = "", rating = "", saved = ""; String url; final formKey = new GlobalKey<FormState>(); final databaseReference = Firestore.instance; String uID; @override

How do I dispatch multiple actions in react-native using hooks?

☆樱花仙子☆ 提交于 2021-01-29 07:51:51
问题 From the code below, I am trying to dispatch two actions that take the registered name and surname of a logged in user from the firestore database user collection and updates the name and surname state in my app. However, for some reason, only the second action gets dispatched. The surname state in my app gets updated but the name state remains empty. I've tried using an async function to call the dispatch but still nothing. I've tried moving the dispatch code to different sections of the

Is there any standard firestore query to get random documents?

早过忘川 提交于 2021-01-29 07:40:36
问题 I am trying to get multiple random documents from a dynamic collection. Until know, I have thought to do it using simple queries, something like this: Pseudocode arr = []; while (arr.length < 5) { // Start the query at a random position startAt = Math.random() * collection.size; randomDoc = await dbRef.startAt(startAt).limit(1).get( ... ); arr.push(randomDoc); } Here, firstly, I have to get the collection size, as it can be 0 or bigger. Then, select a random document using a kind of "db

Authenticate user in Share Extension with Firebase

非 Y 不嫁゛ 提交于 2021-01-29 07:29:58
问题 I've been struggling with his for quite some time now.. I have an app and also a Share Extension . Inside the Share Extension the user needs to be authenticated so he can make requests to my Cloud-Firestore (I set up the security rules so only authorized user can access data). However I am not able to authenticate the user inside my Share Extension . I already checked out Firebase Documentation and this SO-Question but that didn't help me. In my case the user can sign in with Email, Google,