Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

<input class="form-control" type="text" name="name" value="<%= product.name %>" placeholder="name">
product is not defined
This is my route file:
const express = require('express')
const router = express.Router()
const imageMimeTypes = ['image/jpeg', 'image/png', 'images/gif']
//GET product model
var Product = require('../models/product')
//GET Category model
var Category = require('../models/category')
//GET All product Page
router.get('/', async(req, res) => {
let query = Product.find()
if (req.query.name != null && req.query.name != '') {
query = query.regex('name', new RegExp(req.query.name, 'i'))
}
try {
const products = await query.exec()
res.render('admin/products', {
products: products,
searchOptions: req.query
})
} catch {
res.redirect('/')
}
});
//GET category page
router.get('/add-product', async(req, res) => {
res.render('admin/add_product')
});
//POST Add page
router.post('/', async(req, res) => {
const product = new Product({
name: req.body.name,
category: req.body.category,
price: req.body.price,
shopName: req.body.shopName,
district: req.body.district,
productCount: req.body.productCount,
description: req.body.description
})
saveCover(product, req.body.cover)
try {
const newProduct = await product.save()
// res.redirect(`products/${newProduct.id}`)
res.redirect(`products`)
} catch {
renderNewPage(res, products, true)
}
});
async function renderNewPage(res, products, hasError = false) {
try {
const categories = await Category.find({})
const params = {
categories: categories,
product: product
}
if (hasError) params.errorMessage = 'Error Adding Product'
res.render('admin/add_product', params)
} catch {
res.redirect('/products')
}
}
function saveCover(book, coverEncoded) {
if (coverEncoded == null) return
const cover = JSON.parse(coverEncoded)
if (cover != null && imageMimeTypes.includes(cover.type)) {
product.productImage = new Buffer.from(cover.data, 'base64')
product.productImageType = cover.type
}
}
module.exports = router;
Niketan Sharma
819167b5336c456e9ad38395fec1c5
SarkariResultht
e3002a14a547406799fe27a6abf211
9e483d26583f44f6bafe369a29b405
keneucker
keneucker
Shamoil Khan
Frederik
f25932a0b984430fb48c4256f1aaad
0a2e7912d2f74bccbaac42bf8f769b