我正在尝试使用Swift REST API在Firestore上创建一个文档,因为我无法将Firebase API与应用程序剪辑结合使用.正如您所见,我要创建和更新的文档非常复杂:
{
"name": "projects/my_project/databases/(default)/documents/Sessione/LvpTBoUgjVWY0Gchxxxx",
"fields": {
"device_os": {
"stringValue": "iOS"
},
"data_fine_user_session": {
"stringValue": "2022/04/22 16:30:11"
},
"ref_catalogo": {
"referenceValue": "projects/my_project/databases/(default)/documents/Brand/rxnBLnp736gqjFBNxxxx"
},
"user_metrics": {
"arrayValue": {
"values": [
{
"mapValue": {
"fields": {
"metricResult": {
"doubleValue": 6.27
},
"point1": {
"integerValue": "0"
},
"metricTitle": {
"stringValue": "DBP"
},
"metricDescription": {
"stringValue": "Distanza Pupillare"
},
"metricDescriptionEn": {
"stringValue": "Distance between pupils"
},
"point2": {
"integerValue": "0"
}
}
}
},
{
"mapValue": {
"fields": {
"metricResult": {
"doubleValue": 13.61
},
"metricTitle": {
"stringValue": "FWM"
},
"metricDescription": {
"stringValue": "Ampiezza viso alla bocca"
},
"point1": {
"integerValue": "937"
},
"point2": {
"integerValue": "1059"
},
"metricDescriptionEn": {
"stringValue": "Face Width at Mouth"
}
}
}
},
{
"mapValue": {
"fields": {
"point1": {
"integerValue": "20"
},
"metricResult": {
"doubleValue": 18.78
},
"metricDescription": {
"stringValue": "Lunghezza Viso"
},
"point2": {
"integerValue": "1048"
},
"metricDescriptionEn": {
"stringValue": "Face Length"
},
"metricTitle": {
"stringValue": "FL"
}
}
}
}
]
}
},
"total_time": {
"doubleValue": 89
},
"device": {
"stringValue": "Device Type: iPhone - Device iPhone Xʀ - Manufacturer: Apple - Screen Size: 6.1 - OS Version: 15.4.1 - ID: 731257E4-0849-418D-98C7-D7D4D94D1DF8"
},
"lista_occhiali_visualizzati": {
"arrayValue": {
"values": [
{
"mapValue": {
"fields": {
"listaModelliProvati": {
"arrayValue": {
"values": [
{
"mapValue": {
"fields": {
"tagliaRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Taglia/CDouOWmMqijUafJfxxxx"
},
"timeStart": {
"stringValue": "2022/04/22 16:29:59"
},
"modelRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Modello/7Bj6y4pGXsC5hiTsxxxx"
},
"totalSeconds": {
"doubleValue": 58
}
}
}
}
]
}
},
"nome_occhiale": {
"stringValue": "Lady"
},
"lineaRef": {
"referenceValue": "projects/my_project/(default)/documents/Linea/aeeDNuY9xEvRvyM5cQgI"
},
"glassesRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Occhiale/28GLxiAHh7vIl3RWJy5J"
}
}
}
},
{
"mapValue": {
"fields": {
"glassesRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Occhiale/5eXmTJHVXZ5L15EyVpMX"
},
"listaModelliProvati": {
"arrayValue": {}
},
"lineaRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Linea/aeeDNuY9xEvRvyM5cQgI"
},
"nome_occhiale": {
"stringValue": "Yamir"
}
}
}
},
{
"mapValue": {
"fields": {
"listaModelliProvati": {
"arrayValue": {
"values": [
{
"mapValue": {
"fields": {
"modelRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Modello/FXZ3itkCgQ1OKfq0xxxx"
},
"timeStart": {
"stringValue": "2022/04/22 16:30:08"
},
"totalSeconds": {
"doubleValue": 8
},
"tagliaRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Taglia/SwlZFxWovP4WWc7Rxxxx"
}
}
}
}
]
}
},
"nome_occhiale": {
"stringValue": "Wing"
},
"lineaRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Linea/aeeDNuY9xEvRvyM5xxxx"
},
"glassesRef": {
"referenceValue": "projects/my_project/databases/(default)/documents/Occhiale/5FInfbajgjnpAJz2xxxx"
}
}
}
}
]
}
},
"device_id": {
"stringValue": "731257E4-0849-418D-98C7-D7D4D94D1DF8"
},
"modelRefs": {
"arrayValue": {
"values": [
{
"stringValue": "FXZ3itkCgQ1OKfq0xxxx"
},
{
"stringValue": "7Bj6y4pGXsC5hiTsxxxx"
}
]
}
},
"glassesRefs": {
"arrayValue": {
"values": [
{
"stringValue": "5eXmTJHVXZ5L15Eyxxxx"
},
{
"stringValue": "28GLxiAHh7vIl3RWxxxx"
},
{
"stringValue": "5FInfbajgjnpAJz2xxxx"
}
]
}
},
"is_first_session": {
"booleanValue": false
},
"data_inizio_sessione": {
"stringValue": "2022/04/22 16:27:54"
},
"lineaRefs": {
"arrayValue": {
"values": [
{
"stringValue": "aeeDNuY9xEvRvyM5xxxx"
}
]
}
}
},
"createTime": "2022-04-22T14:28:46.615261Z",
"updateTime": "2022-04-22T14:30:11.231081Z"
}
为了实现这一点,我必须做些什么?到目前为止,我还没有找到太多关于它的文档.我读了一些关于堆栈溢出的答案,但没有一个能真正解决我的问题,我不能完全理解如何编写代码,因为没有任何可以从中获得灵感的地方.感谢所有愿意帮助的人.