【问题标题】:How to send the formated data to fire store如何将格式化的数据发送到 Firestore
【发布时间】:2020-09-25 17:30:59
【问题描述】:

我的数据很少,如下所示:

Name (string), 
Age (string),
Number (string), 
ContactList (Array of string), 
messages (Array of string),
callHistory (Array of string)

我从每个屏幕收集的所有这些值,并将其保存在AsyncStorage。我想以与括号中提到的相同格式发送这些数据。但是我怎样才能格式化并发送到firestore?我是新手。我尝试了所有的方法,但无法理解如何进行格式化并发送到消防商店。

在我的 Firestore 中,我的收藏将如下所示:

Details (集合名称) -> UserID(DocumentID) ->Data[]` (在这个数据中我需要保存为数组。就像每次我将数据推送到这个集合时一样我需要将所有内容保存在数组中(索引格式))。

我该怎么做?

任何帮助都会很棒!

【问题讨论】:

    标签: javascript reactjs react-native google-cloud-firestore


    【解决方案1】:

    您可以分两步完成。

    1) 从 AsyncStorage[1] 中获取数据,以您想要的格式将其存储在变量中。

    2) 在firestore中设置变量。[2]

     db.collection("Details").doc("UserID").set(variable).then(function(){
     });
    

    [1]https://reactnative.dev/docs/asyncstorage#getitem

    [2]https://cloud.google.com/firestore/docs/manage-data/add-data#data_types

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-10
      • 2022-11-02
      • 1970-01-01
      • 2020-05-17
      • 2017-11-16
      • 1970-01-01
      • 2020-02-26
      相关资源
      最近更新 更多