当我尝试运行我的代码时,它显示“MongoError:Tailed Cursor 中没有更多文档”。
const mongoose = require('mongoose');
const Schema = require('mongoose').Schema;
const dataSchema = new Schema({
id: String,
name: Number,
timestamp: Number
}, { capped: 5000000 });
const CappedData = mongoose.model('cappedData', dataSchema);
const dataCursor = CappedData.find({}).tailable(true, {awaitData: true}).cursor();
dataCursor.on('data', doc => {
console.log(data);
});