nodejs+ejs+express 编写的js+html无法获取MongoDB内的数据

我是照着一个视频教程做的:

https://www.youtube.com/watch?v=yH593K9fYvE

完成的代码是这样的:

js文件:

const express = require('express');
const mongoose = require('mongoose');
const app = express();
const ejs = require('ejs');

app.set('view engine','ejs');

mongoose.connect('mongodb://121.5.***.**:27017/Python');

const python_result = {
    content: String
}

const Python = mongoose.model("content", python_result);

app.get('/', (req, res) => {
    Python.find({}, function(err, test){
        res.render('index', {
            ResultList: test
        })
    })
})

app.listen(4000, function() {
    console.log('server is running')
})

 

index.ejs文件:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Python Result</title>
</head>

<body>
    <h1>try3</h1>
    <% for(i=0; i< ResultList.length; i++) {%>
        <li><a><%= ResultList[i].content %></a></li>
    <% } %>
</body>

</html>

 

数据库如图:

 

显示结果只有html的<h1>标签,

数据库内容没有显示出来

 

 

const Python = mongoose.model("content", python_result);

 

content 替换成 你的表名称:test

const Schema = mongoose.Schema;  //新增

 

//模型

const TestSchema = new Schema({

  content: {

    type: String

  }

})

 

const Python = mongoose.model("test", TestSchema);