我的代码
const mongoose = require('mongoose');
const Tutorial = require('./models/Tutorial');
async function createTutorial() {
try {
console.log('guy Incognito');
const doc = await Tutorial.create({ title: 'bill ', body: 'Bill Russel was great player!' });
console.log(`randomTextabcde\n${doc}`);
} catch (err) {
console.log(err);
}
}
createTutorial();
在模型/教程中
const mongoose = require('mongoose');
const TutorialSchema = new mongoose.Schema({
title: String,
body: String,
createdAt: {
type: Date,
default: Date.now,
},
});
module.exports = mongoose.model('Tutorial', TutorialSchema);
当我从终端运行我的代码时,
node index.js
节目
guy Incognito
似乎 promise 没有解决.. 为什么?
红颜莎娜
萧十郎
相关分类