- piuchebuono: possiblità di modificare l'immagine dalla scheda direttamente
- migliorata di poco la grafica dell'immagine.
This commit is contained in:
@@ -230,7 +230,7 @@ module.exports.getProductByCode = function (idapp, code) {
|
||||
module.exports.replaceProductImgToImageFile = async function () {
|
||||
const ProductInfo = this;
|
||||
|
||||
let abilitaserver = false;
|
||||
let abilitaserver = true;
|
||||
|
||||
if (abilitaserver) {
|
||||
// const result = await ProductInfo.updateMany({ "img": { $exists: true } }, { $rename: { 'img': 'imagefile' } });
|
||||
@@ -240,9 +240,9 @@ module.exports.replaceProductImgToImageFile = async function () {
|
||||
|
||||
// Aggiorna ciascun documento
|
||||
for (let doc of documents) {
|
||||
if (doc.img && doc.img.startsWith('/upload/products/')) {
|
||||
if (doc.img && doc.img.startsWith('upload/products/')) {
|
||||
// Rimuovi il prefisso '/upload/products' dal campo `img`
|
||||
doc.imagefile = doc.img.replace(/^\/upload\/products\//, '');
|
||||
doc.imagefile = doc.img.replace(/^\upload\/products\//, '');
|
||||
doc.img = undefined; // Può anche rimuovere il campo img corrente se desiderato
|
||||
await doc.save(); // Salva il documento aggiornato
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user