topology was destroyed
- Dominant language
- JavaScript
- Stars
- 1.8k
- Forks
- 180
- PR merge metrics
- No merged PRs in 30d
Description
I tried to make connection to mongodb and use the find function. but no hope with the toplogy was destroyed error
`var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
mongoose.connect('localhost:27017/test');
var Schema = mongoose.Schema;
var userDataSchema = new Schema({
title: {type: String, required: true},
content: String,
author: String
}, {collection: 'user-data'});
var UserData = mongoose.model('UserData', userDataSchema);
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index');
});
router.get('/get-data', function(req, res, next) {
UserData.find()
.then(function(doc) {
res.render('index', {items: doc});
});
});
router.post('/insert', function(req, res, next) {
var item = {
title: req.body.title,
content: req.body.content,
author: req.body.author
};
var data = new UserData(item);
data.save();
res.redirect('/');
});
router.post('/update', function(req, res, next) {
var id = req.body.id;
UserData.findById(id, function(err, doc) {
if (err) {
console.error('error, no entry found');
}
doc.title = req.body.title;
doc.content = req.body.content;
doc.author = req.body.author;
doc.save();
})
res.redirect('/');
});
router.post('/delete', function(req, res, next) {
var id = req.body.id;
UserData.findByIdAndRemove(id).exec();
res.redirect('/');
});
module.exports = router;
`
But I tried to use mongo db nodejs driver or mongoose, everything works correct
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the supplied Express/Mongoose connection and UserData.find() path against MongoDB, then inspect Monk's connection entry points for how this error is surfaced. No repository file or test is named, and completion would require a maintainer-confirmed root cause and a defined fix or documentation change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, javascript, mongodb, node.js
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100