My question is: How can I get all documents where category === 'something'?
model.js (model):
var Schema = new mongoose.Schema({
category: String,
title: String
});
Mongoose:
var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
var Model = require('../models/model.js');
router.get('/:category', function(req, res, next) {
Model.find({ category: req.params.category}, function(err, post){
if (err) return next(err);
res.json(post);
});
});
JS in my controller:
Model.get({category: 'something'}, function() {
//callback
});
Goal: Once I am able to get these documents, I want to batch update the category property, but I can't get the query to work. I could get the ids and update individually, but that's bad, mmkay.
I want to thank you in advance for your responses. I sincerely appreciate it.