【发布时间】:2020-11-13 01:20:34
【问题描述】:
我一直试图在 firestore 中构建我的数据库
我的 json 看起来像这样
{"UID":"myusrsid","PhotoList":[{"PhotoID":333,"PhotoURL":"url1ofphone"}, {"PhotoID":332,"PhotoURL":"url2ofphoto"} ]}
这里的 UID 是用户 ID,它对用户来说是唯一的,其中的这个 UID 有照片列表,其中有照片 ID 和它的 url
因此,如果用户 ID 已存在,则每当用户上传新照片时,都应将照片添加到照片列表中 如果是新用户,则应创建新用户的 UID,并将照片添加到照片列表中
我一直在挠头来构建这个
public class Users
{
public string UID { get; set; }
public List<PhotoList> PhotoList { get; set; }
}
public class PhotoList
{
public int PhotoID { get; set; }
public string PhotoURL { get; set; }
}
这是我计划发送和接收数据的模型
我知道要检索和存储数据,现在唯一需要帮助的是我应该如何构建它。我正在使用节点 js
这就是我现在一直在做的事情
const imageBody = {
uid,
imageBase64String,
} = req.body;
await db.collection('users').doc(imageBody.uid).collection('Photos').doc(imageBody.imageBase64String).create({
url : imageBody.imageBase64String
});
【问题讨论】:
-
Firebase 实时数据库和 Cloud Firestore 是两个独立的数据库。请仅使用相关标签标记您的问题,不要同时使用两者。
标签: node.js firebase google-cloud-firestore google-cloud-functions