google-cloud-firestore

Delete data from Firestore dynamically

女生的网名这么多〃 提交于 2020-07-19 18:59:06
问题 I'm building a project with React & Redux & Firestore, I know how to delete/update/add etc.. But when I have 2 subcollections with dynamic field, I couldn't find any solution to delete it. If you look at the picture, I have the table ID and user ID, but the fields are 0, 1, 2 and so on. How can I delete a field from tableGuests? Maybe the structure is not good and could be better? guests > user id > userTables > table id > tableGuests which is an array. 回答1: How can I delete a field from

Firestore query orderBy not working?

喜夏-厌秋 提交于 2020-07-19 07:36:11
问题 FutureBuilder with a Firestore query on a field of Type timestamp comes back with no data in snapshot. However, the same query without the orderBy works just fine. What am I missing ? Thanks for the help. // Working code future: Firestore.instance.collection('messages').where('toid',isEqualTo: _emailID).getDocuments(), builder: (context, snapshot) ... // Not Working - returns to if(!snapshot.hasData) future: Firestore.instance.collection('messages').where('toid',isEqualTo: _emailID).orderBy('

Firestore query for loop with multiple values

独自空忆成欢 提交于 2020-07-19 05:58:26
问题 I am attempting to retrieve a number of Firestore documents using data held in a string. The idea is that for each value in the array, i'd use Firestore query to retrieve the document matching that query and push it to another array. I am having a few issues achieving this. So far i've tried: exports.findMultipleItems = functions.https.onRequest((request, response) => { var list = ["item1", "item2", "item3", "item4"]; var outputList = []; for (var i = 0; i < list.length; i++) { console.log(

Why can't I convert a Number into a Double?

时光怂恿深爱的人放手 提交于 2020-07-18 21:09:24
问题 weight is a field (Number in Firestore), set as 100 . int weight = json['weight']; double weight = json['weight']; int weight works fine, returns 100 as expected, but double weight crashes ( Object.noSuchMethod exception) rather than returning 100.0 , which is what I expected. However, the following works: num weight = json['weight']; num.toDouble(); 回答1: When parsing 100 from Firestore (which actually does not support a "number type", but converts it), it will by standard be parsed to an int

Why can't I convert a Number into a Double?

人走茶凉 提交于 2020-07-18 21:08:08
问题 weight is a field (Number in Firestore), set as 100 . int weight = json['weight']; double weight = json['weight']; int weight works fine, returns 100 as expected, but double weight crashes ( Object.noSuchMethod exception) rather than returning 100.0 , which is what I expected. However, the following works: num weight = json['weight']; num.toDouble(); 回答1: When parsing 100 from Firestore (which actually does not support a "number type", but converts it), it will by standard be parsed to an int

Why can't I convert a Number into a Double?

不问归期 提交于 2020-07-18 21:07:23
问题 weight is a field (Number in Firestore), set as 100 . int weight = json['weight']; double weight = json['weight']; int weight works fine, returns 100 as expected, but double weight crashes ( Object.noSuchMethod exception) rather than returning 100.0 , which is what I expected. However, the following works: num weight = json['weight']; num.toDouble(); 回答1: When parsing 100 from Firestore (which actually does not support a "number type", but converts it), it will by standard be parsed to an int

How to save extra info during user signup process using firebase authentication

半世苍凉 提交于 2020-07-15 06:24:09
问题 I'm building a website where I've integrated firebase authentication for login/signup of site users. Users can login/signup via either email-password or mobile OTP method. I'm using official firebase js Auth UI Widget: firebaseui-web for this authentication process. While signup, I also want to capture additional user details like full name, gender, age etc. I found 2 approaches on the web for this: Store extra info in firestore after successful signup. Issue with this approach is I want to

How to Delete all documents in collection in Firestore with Flutter

谁都会走 提交于 2020-07-15 04:40:11
问题 I have a firestore database. My project plugins: cloud_firestore: ^0.7.4 firebase_storage: ^1.0.1 This have a collection "messages" with a multiple documents. I need to delete all documents in the messages collection. But this code fail: Firestore.instance.collection('messages').delete(); but delete is not define how is the correct syntax? 回答1: Ah. The first answer is almost correct. The issue has to do with the map method in dart and how it works with Futures. Anyway, try using a for loop

How to Delete all documents in collection in Firestore with Flutter

戏子无情 提交于 2020-07-15 04:40:03
问题 I have a firestore database. My project plugins: cloud_firestore: ^0.7.4 firebase_storage: ^1.0.1 This have a collection "messages" with a multiple documents. I need to delete all documents in the messages collection. But this code fail: Firestore.instance.collection('messages').delete(); but delete is not define how is the correct syntax? 回答1: Ah. The first answer is almost correct. The issue has to do with the map method in dart and how it works with Futures. Anyway, try using a for loop

Flutter: Update specific index in list (Firestore)

一曲冷凌霜 提交于 2020-07-13 15:09:45
问题 How exactly do you update a specific value in a list based on it's index? For example, in the following list: 0 [ { first_name: name0, last_name: lastName0, } ] 1 [ { first_name: name1, last_name: lastName1, } ] How can I update only "lastName1"? At the moment, I'm using a bit of a hacky solution using ArrayUnion, which uses data comparison instead of the actual index (I load the values into a form, delete the original value and then re-add it again): // Retrieve data at index, load into form