typescript - Loopback 4 - 从 Firestore 获取子集合
问题描述
Loopback 4 在这里有一个社区维护的 Firestore 连接器:https ://github.com/dyaa/loopback-connector-firestore
如何从以下集合中获取子集合房屋:
{
village: {
id: "yaOh(37Na",
name: "Greenwich",
houses: {
house01: {
address: "1st Street"
},
house02: {
address: "2nd Street"
}
}
}
}
以下代码段仅返回浅层结果:
const village = await this.villageRepository.findOne({where: {id: "yaOh(37Na"}});
console.log(village); // returns {id: "yaOh(37Na", name: "Greenwich"}
解决方案
在从集合中读取的 Firestore 中,仅从该集合中读取数据,而不是从其下的集合中读取数据。也没有 API 可以自动从子集合中读取数据。
您必须为要从中获取数据的每个子集合执行单独的读取操作。
推荐阅读
- google-apps-script - 复制过滤条件谷歌脚本的值
- django - 我的 Django 模型中的一个字段已经存在于 PostgreSQL 数据库中
- python - 找不到指定的程序
- .net - 传递 --no-build 时如何跳过 .csproj 中的目标?
- stored-procedures - 只返回存储过程的第一个参数
- c# - Mac 有服务器资源管理器吗?
- gcc - LinuxBrew 不安装最新版本的 gcc?
- javascript - React.js 上 UseEffect 中的变量
- javascript - 用Javascript解码图像
- jenkins - 带有 jenkins + github 的 CD/CI