我的iOS应用程序的firestore缓存似乎与Firestore不同步.结果我不得不禁用持久性.无论如何重置缓存?有没有办法确保它不断同步?我所做的只是从数据库中删除文件!
是否可以查询firebase以获取集合中文档的字段,其中特定字段的数组中的元素数大于0
在我的示例中,每个文档都有一个名为“ people”的字段,其中包含一个整数数组(或者该数组为空)。
我的搜索总是返回0个文档,但是当我在firestore数据库管理面板中搜索时,可以看到一些文档。
import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
admin.initializeApp();
var db = admin.firestore();
export const helloWorld = functions.https.onRequest(function(req,res)
{
var all_users = db.collection('users');
var query = all_users.where("people.length", ">", 0).get().then(snapshot =>
{
let docs = snapshot.docs;
//return 1st document found
res.send(docs[0].data());
});
query.catch(error =>
{
res.status(500).send(error);
});
});
Run Code Online (Sandbox Code Playgroud)