Update differnt fields in different Documents in Mongodb using Nodejs/Express
Budget: $10 – $30 USD
in the database we have following document called "Product"
[
{
_id: new ObjectId("638513a4ab6217c642c0cdc7"),
name: 'car',
quantity: 30,
},
{
_id: new ObjectId("6385142fab6217c642c0cdcc"),
name: 'door',
quantity: 5,
}
]
----------------------------------------------------------------------------------------------------------------------------------------------------------
incrementArray = [ 2 , 3]
>>> I need to increase the quantity of the "window" and the "door" dynamically by using the incrementArray , Please find below my code where you can introduce your solution when we call the router at "/".
----------------------------------------------------------------------------------------------------------------------------------------------------------
var express = require('express');
var router = express.Router();
var Product = require('../models/product');
router.get('/', function(req, res, next) {
const IDs = ["638513a4ab6217c642c0cdc7","638513a4ab6217c642c0cdc7"]
const incrementArray = [ 2 , 3]
// Example to query in Database
// Product.find({})....
return res.render('index');
});
[
{
_id: new ObjectId("638513a4ab6217c642c0cdc7"),
name: 'car',
quantity: 30,
},
{
_id: new ObjectId("6385142fab6217c642c0cdcc"),
name: 'door',
quantity: 5,
}
]
----------------------------------------------------------------------------------------------------------------------------------------------------------
incrementArray = [ 2 , 3]
>>> I need to increase the quantity of the "window" and the "door" dynamically by using the incrementArray , Please find below my code where you can introduce your solution when we call the router at "/".
----------------------------------------------------------------------------------------------------------------------------------------------------------
var express = require('express');
var router = express.Router();
var Product = require('../models/product');
router.get('/', function(req, res, next) {
const IDs = ["638513a4ab6217c642c0cdc7","638513a4ab6217c642c0cdc7"]
const incrementArray = [ 2 , 3]
// Example to query in Database
// Product.find({})....
return res.render('index');
});