当在postman 中显示此错误时,我try 在NodeJS和FireStore中使用筛选器获取数据

"Cannot read properties of undefined (reading '_internalPath')"

我的代码

const getAllWords = async (req, res, next) => {
     let categoryName = "fruits"
    
    try {
        const word = await firestore.collection('12words');
        const data = await word.where({categoryName}).get();
        const wordArray = []; 
        if(data.empty) {
            res.status(404).send('No words12  found');
        }else {
            data.forEach(doc => {
                const words = new Word12(
                    doc.id,
                    doc.data().name,
                    doc.data().categoryName,
                    
                );
                wordArray.push(words);
            });
            res.send(wordArray);
        }
    } catch (error) {
        res.status(400).send(error.message);
    }
}

推荐答案

.where()接受3个参数(fieldPath, opStr, value),但您只传递了1个对象.try 重构代码,如下所示:

// replace fieldName with the field name in document
const data = await word.where("fieldName", "==", categoryName).get();

Javascript相关问答推荐

*ngFor和@代表输入decorator 和选角闭合

使用JavaScript在ionic Web应用程序中更新.pane和.view的背景 colored颜色

如何访问Json返回的ASP.NET Core 6中的导航图像属性

如何才能拥有在jQuery终端中执行命令的链接?

在React中获取数据后,如何避免不必要的组件闪现1秒?

提交表格后保留Web表格中的收件箱值?

. NET中Unix时间转换为日期时间的奇怪行为

MongoDB中的引用

Redux查询多个数据库Api reducerPath&

在286之后恢复轮询

虚拟滚动实现使向下滚动可滚动到末尾

当id匹配时对属性值求和并使用JavaScript返回结果

在数组中查找重叠对象并仅返回那些重叠对象

当我在Reaction中创建一个输入列表时,我的输入行为异常

将对象推送到数组会导致复制

为什么当我更新数据库时,我的所有组件都重新呈现?

如何防止ionic 输入中的特殊字符.?

判断函数参数的类型

使用jQuery每隔几秒钟突出显示列表中的不同单词

浮动标签效果移除时,所需的也被移除