如何动态创建 Firebase Firestore Cloud Function 查询?
How can I dynamically create Firebase Firestore Cloud Function queries?
我正在尝试动态生成查询。
我有一个很大的对象,比如位置和价格数据。但是我从请求中得到了这些数据。如果每个查询对象都是链式函数,我如何动态地使用该数据?
理想情况下,我想转换这样的东西...
const wheres = [
{ key: 'price', operator: '>=', value: '1000' },
{ key: 'price', operator: '<=', value: '2000' }
]
...到...
admin
.firestore()
.collection(`rentals`)
.where(`price`, `>=`, `1000`)
.where(`price`, `<=`, `2000`)
我正在尝试动态生成查询。
我有一个很大的对象,比如位置和价格数据。但是我从请求中得到了这些数据。如果每个查询对象都是链式函数,我如何动态地使用该数据?
理想情况下,我想转换这样的东西...
const wheres = [
{ key: 'price', operator: '>=', value: '1000' },
{ key: 'price', operator: '<=', value: '2000' }
]
...到...
admin
.firestore()
.collection(`rentals`)
.where(`price`, `>=`, `1000`)
.where(`price`, `<=`, `2000`)