【发布时间】:2019-02-02 20:58:40
【问题描述】:
我已经使用 Google Firebase 设置了身份验证过程。我现在希望开始使用 Firestore 数据库 - 因为我需要使用多个集合 - 并且 JSON 文件中有大量数据需要导入。
JSON 文件如下所示。我将只发布前两个条目,但总共有 60 个,而且我自己也无法输入。
如果有人可以指导我完成有关如何利用脚本解决此问题的步骤,将不胜感激。谢谢!
我曾尝试利用 Stack 上的其他一些帖子,但正是脚本的使用让我大吃一惊。
[
{
"FirstName": "Nickeil",
"LastName": "Alexander-Williams",
"Position": 2,
"Age": 19,
"CollegeYear": 2,
"Height": 77,
"DisplayHeight": "6-5",
"Weight": 205,
"College": "Virginia Tech",
"Consistency": 46,
"Greed": 72,
"Loyalty": 58,
"PlayForWinner": 16,
"PlayingTime": 26,
"Personality": 53,
"Durability": 47,
"WorkEthic": 75,
"DunkRate": 56,
"RARate": 3,
"DriveKick": 58,
"DriveShot": 0,
"PostUp": 0,
"PullUp": 17,
"CS": 32,
"Pass": 68,
"LocATB": 30,
"LocCorner": 81,
"LocMidrange": 27,
"LocPaint": 42,
"FG_RA": 58,
"FG_ITP": 58,
"FG_MID": 31,
"FG_COR": 18,
"FG_ATB": 67,
"FT": 0,
"Scoring": 35,
"Passing": 40,
"Handling": 41,
"OReb": 51,
"DReb": 61,
"Block": 52,
"Steal": 23,
"DrawFoul": 5,
"Defender": 54,
"Discipline": 75,
"BballIQ": 65,
"FG_RA_POT": 65,
"FG_ITP_POT": 65,
"FG_MID_POT": 38,
"FG_COR_POT": 25,
"FG_ATB_POT": 74,
"FT_POT": 7,
"Scoring_POT": 42,
"Passing_POT": 47,
"Handling_POT": 48,
"OReb_POT": 58,
"DReb_POT": 68,
"Block_POT": 59,
"Steal_POT": 30,
"DrawFoul_POT": 12,
"Defender_POT": 61,
"Discipline_POT": 82,
"BballIQ_POT": 72
},
{
"FirstName": "RJ",
"LastName": "Barrett",
"Position": 2,
"Age": 19,
"CollegeYear": 1,
"Height": 78,
"DisplayHeight": "6-6",
"Weight": 210,
"College": "Duke",
"Consistency": 61,
"Greed": 83,
"Loyalty": 77,
"PlayForWinner": 80,
"PlayingTime": 81,
"Personality": 76,
"Durability": 44,
"WorkEthic": 79,
"DunkRate": 80,
"RARate": 17,
"DriveKick": 51,
"DriveShot": 28,
"PostUp": 20,
"PullUp": 40,
"CS": 45,
"Pass": 35,
"LocATB": 40,
"LocCorner": 84,
"LocMidrange": 35,
"LocPaint": 54,
"FG_RA": 54,
"FG_ITP": 54,
"FG_MID": 39,
"FG_COR": 26,
"FG_ATB": 66,
"FT": 2,
"Scoring": 40,
"Passing": 27,
"Handling": 36,
"OReb": 57,
"DReb": 65,
"Block": 37,
"Steal": 39,
"DrawFoul": 13,
"Defender": 61,
"Discipline": 54,
"BballIQ": 58,
"FG_RA_POT": 61,
"FG_ITP_POT": 61,
"FG_MID_POT": 46,
"FG_COR_POT": 33,
"FG_ATB_POT": 73,
"FT_POT": 9,
"Scoring_POT": 47,
"Passing_POT": 34,
"Handling_POT": 43,
"OReb_POT": 64,
"DReb_POT": 72,
"Block_POT": 44,
"Steal_POT": 46,
"DrawFoul_POT": 20,
"Defender_POT": 68,
"Discipline_POT": 61,
"BballIQ_POT": 65
},
.
.
.
]
【问题讨论】:
-
使用 firebase,您可以将您的 json 对象传递给 update 方法,然后它就会写入它。问题出在哪里?
-
@Mocas 你能解释一下吗?我当前的程序中有一个 JSON 文件,我正在使用 Firebase 的 Firestore。
标签: reactjs firebase google-cloud-firestore