我遇到了卡住的错误,我是mongodb,expressjs的初学者
我的Index.js:
const mongoose= require('mongoose')
let modelspath ='./models'
fs.readdirSync(modelspath).forEach(function(file){
if(~file.indexOf('.js'))
console.log(file)
require(modelspath +'/' + file) //if block checks weather file ending with .js ext
})
const BlogModel = mongoose.model('Blog')
let testRoute = (req, res) =>
{
console.log(req.params)
res.send(req.params)
}
我的model.blog.js文件
const mongoose = require('mongoose')
const Schema = mongoose.Schema;
let blogSchema =new Schema(
{
blogId :{
type: string,
unique:true
},
mongoose.model('Blog',blogSchema);
const express =require('express')
//here we can find routees logic path
const control =require('./../controllers/controller')
let setRouter =(app) =>{
//here we are getting our logics and assigning for a Http verbs (get,post,put,del)
app.get('/test/route/:param1/:param2',control.testRoute)
app.get('/example',control.example)
// app.post('/hello', control.postmethod)
}
module.exports={
setRouter:setRouter
}
有人可以帮助我解决这个错误