我收到 Firebase 错误:“未知字段过滤器操作”

Mar*_*ist 7 javascript firebase vue.js vuejs2 google-cloud-firestore

有谁知道错误“FirebaseError:未知的字段过滤器操作”是什么意思?

我正在开发一个 Vue 项目,我将播放列表存储在 Firestore 数据库中,并且我想要进行 CRUD 操作。当我尝试从数据库接收单个文档时,会弹出此错误。我不知道在哪里寻找错误。

<template>
    <div v-if="playlist">
        <h2> {{ playlist.title }} </h2>
    </div>
</template>

<script>

import db from '../firebase/config'
export default {

  data() {
      return {
          playlist: null
      }
  },
  created(){
      let ref = db.collection('playlists').where('slug', '=', this.$route.params.playlist_slug)
      ref.get().then(snapshot => {
          snapshot.forEach(doc => {
              this.playlist = doc.data()
              this.playlist.id = doc.id
          })
      })
  }
 
}
</script>

<style scoped>

</style>
Run Code Online (Sandbox Code Playgroud)

Fra*_*len 5

您在查询中使用的运算符是=,它不是 Firestore 的已知查询运算符。Firestore 用于==相等过滤器。

所以:

db.collection('playlists').where('slug', '==', this.$route.params.playlist_slug)
Run Code Online (Sandbox Code Playgroud)