Mongoose Not Saving Data

后端 未结 6 2128
有刺的猬
有刺的猬 2021-01-14 01:50

I am having trouble with a simple query on my database. Following this tutorial: https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4 when Model.find() i

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-14 02:07

    For this code

    post.title = req.body.title; // Set title (from request) post.content = req.body.content; // Set content (from request)

    could you check

    1. req.body.title and req.body.content are not undefined?
    2. do you set the field in your Post schema as

      var PostSchema = new Schema({ title: String, content: String });

提交回复
热议问题