类型错误:无法在exports.getTodos (/home/jk/Documents/webPractice/todoapp/helpers/helpers.js:5:13) 处读取未定义的属性“查找”

这是我的助手代码 *这是在尝试将 get.Todos 导出到 index.js 文件时导致错误的文件,它在将数据插入 mongo 数据库时工作正常,但在尝试使用 find() 方法访问数据库中的数据时一直显示这些错误*

    const db = require('../model'); 

    exports.getTodos = function(req,res){
        db.Todo.find()
        .then(function(foundTodo){
            res.json(foundTodo)
        }).catch(function(err){
            res.send(err);
        })
    }
    exports.createTods = function(req,res){
        db.Todo.create(req.body)
        .then(function(newTodo){
            res.json(newTodo); 
        }).catch(function(e){
            res.send(e);
        })
     }
     exports.getTodo = function(req,res){
        db.Todo.findbyId(req.params.todoId)
        .then(function(foundId){
            res.json(foundId)
        }).catch(function(err){
            res.send(err);
        })
    }
    exports.updateTodos = function(req,res){
        db.Todo.findOneAndUpdate({_id : req.params.todoId},req.body,{new:true})
        .then(function(updateddata){
            res.json(updateddata);
        }).catch(function(err){
            res.send(err);
        })
    }
    exports.deleteTodo = function(req,res){
        db.Todo.remove({_id:req.params.todoId})
        .then(function(){
            res.json({message:"Removed"}); 
        }).catch(function(err){
            res.send(err);
        })
    }

    module.exports = exports;

这是我的模型

const mongoose = require('mongoose'); 

const todoSchema = mongoose.Schema({
    name: {
        type : String,required : true
    },completed :{
        type:Boolean,default:false
    },date_Created : {
        type:Date,default: Date.now
    } 
  
}); 

const Todo = mongoose.model('Todo',todoSchema); 


module.exports = Todo; `

zyfv002 回答:类型错误:无法在exports.getTodos (/home/jk/Documents/webPractice/todoapp/helpers/helpers.js:5:13) 处读取未定义的属性“查找”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2450.html

大家都在问