// Define a model for the stories const storyModel = mongoose.model('Story', { title: String, content: String, category: String });
// Connect to MongoDB mongoose.connect('mongodb://localhost/banglachotikahini', { useNewUrlParser: true, useUnifiedTopology: true }); // Define a model for the stories const
// Route to get stories from a specific archive app.get('/archive/:category', async (req, res) => { try { const stories = await storyModel.find({ category: req.params.category }); res.json(stories); } catch (err) { res.status(500).json({ message: err.message }); } }); { title: String