javascript - 当向我显示此错误 "Cannot read properties of undefined (reading ' _internalPath') 时,我尝试使用 nodejs 和 firestore 中的过滤器获取数据”

标签 javascript firebase google-cloud-platform google-cloud-firestore

当在 postman 中显示此错误时,我尝试使用 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 个对象。尝试重构代码,如下所示:

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

关于javascript - 当向我显示此错误 "Cannot read properties of undefined (reading ' _internalPath') 时,我尝试使用 nodejs 和 firestore 中的过滤器获取数据”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73850393/

相关文章:

javascript/jquery 选项卡在 IE7、8 或 9 中不起作用

google-cloud-platform - 如何设置 Cloud Composer 以发送电子邮件?

google-cloud-platform - 如何在 Google Workflows 中与 http.call (get) 中收到的 token 进行比较

machine-learning - 使用 sk-learn 模型进行大查询预测

android - Firebase- ML Kit 库无法检测三星 J5 设备中的条码

firebase - 在 Windows 中是否可以在没有输入文件的情况下使用 firebase cli?

javascript - 如何允许最终用户为此模式定义多个 namespace 扩展级别?

javascript - d3.js - 在图表中分组数据

javascript - 如何在 Google Apps 脚本中使用变量作为哈希表键?

ios - 单击段控制表单元格内的按钮后无法执行 segue