mongoose

const mongoose = require('mongoose');
const Schema=mongoose.Schema;
mongoose.connect("mongodb://47.93.52.112:27017/myDb", function(err) {
    console.log('MongoDB 连接成功');
    const stuSchema = new Schema({name:String, age:Number});
    const stu = mongoose.model('stu', stuSchema);
    stu.find().then(function (docs) {
        console.log(docs)
    })
})

posted @ 2018-05-03 13:49  丁少华  阅读(152)  评论(0编辑  收藏  举报