Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 如何使用多个.Where()进行搜索?Vue JS&;火基_Firebase_Vue.js_Google Cloud Firestore_Conditional Statements_Where Clause - Fatal编程技术网

Firebase 如何使用多个.Where()进行搜索?Vue JS&;火基

Firebase 如何使用多个.Where()进行搜索?Vue JS&;火基,firebase,vue.js,google-cloud-firestore,conditional-statements,where-clause,Firebase,Vue.js,Google Cloud Firestore,Conditional Statements,Where Clause,我想查询多个集合的搜索,而不仅仅是品牌。我直接从CloudFireStore查询 到目前为止,我成功地查询了该品牌 我也尝试结合分类和描述,但总是失败 我使用where()直接从firebase调用它 getExchanges({commit, state}, {searched} = {searched: ''}) { commit('resetPagination'); // Here you want to make a call to firebase and a

我想查询多个集合的搜索,而不仅仅是品牌。我直接从CloudFireStore查询

到目前为止,我成功地查询了该品牌

我也尝试结合分类和描述,但总是失败

我使用where()直接从firebase调用它

getExchanges({commit, state}, {searched} = {searched: ''}) {
      commit('resetPagination');
      // Here you want to make a call to firebase and ask for data
      return db
       .collection('exchanges')
       .where('brand', '>=', searched).where('brand', '<=', searched+ '\uf8ff')
       .limit(state.pagination.itemCount)
       .get()
       .then(snapshots => {
         if (snapshots.docs.length === 0) {
            commit('setExchanges', []);
            return []
         }
         const exchanges = snapshots.docs.map(doc => ({...doc.data(), id: doc.id}))
         commit('setExchanges', exchanges)
         commit('setLastItem', snapshots.docs[snapshots.docs.length - 1])
         commit('setPreviousFirstItem', snapshots.docs[0])
         return exchanges
        })
getExchanges({commit,state},{searched}={searched:'}){
提交(“重新分页”);
//在这里,您想打电话到firebase并询问数据
返回数据库
.集合(“交换”)

.where('brand','>=',searched)。where('brand','=',searched)。where('brand'| |'category','当前Cloud Firestore不支持“或”查询。最接近的方法是使用“array contains”和“array contains any”查询并显式设计数据结构以满足查询需要。另一种方法是使用名为的第三方服务

另一点需要注意的是,您的代码

.where('brand' || 'category', '>=', searched).where('brand' || 'category', '<=', searched+ '\uf8ff')

.where('brand'| |'category','>=',search)。where('brand'| |'category','=',search)。where('brand',看起来您正在尝试执行Firestore不支持的逻辑OR查询。您可能对本文感兴趣:(免责声明:我是作者)您好,非常感谢您的建议我将尝试使用数组包含任何感谢或信息,现在我放松为什么它总是失败欢呼Zaidhi CRUD似乎数组包含任何不是用于多个字段,而是用于多个值?
.where('brand' || 'category', '>=', searched).where('brand' || 'category', '<=', searched+ '\uf8ff')
.where('brand', '>=', searched).where('brand', '<=', searched+ '\uf8ff')