First, this code works perfectly since today, I don't know why, this have changed, and I didn't modify it. This is the code:
app.post('/upload', function (req, res){
var tags = req.body.tags.split(" ");
usermodel.findOne({ user: req.session.user }, function (err, user){
console.log(user);
var img = user.imagen.push({
title: req.body.title,
name: req.files.art.name,
author: user.user,
description: req.body.description,
index: user.imagen.length + 1,
path: './users/' + user.user + '/' + req.files.art.name,
dowload: req.body.share,
tags: tags
});
user.save(function (err, suser){
if (err) throw err;
fs.readFile(req.files.art.path, function(err, data){
if (err) throw err;
fs.writeFile(user.path + '/' + req.files.art.name, data, function(err){
if(err) throw err;
res.redirect('/home');
});
});
});
});
And when I checked an user, the imagen array of that user, looks like this '[object Object]'. Why this happens? Any solution for this...?
Thank's advance!
EDITED:
This is the Schema:
var userschema = new mongoose.Schema({
user: String,
pass: String,
imagen: [{
title: String,
name: String,
views: Number,
type: String,
author: String,
tags: [String],
description: String,
index: Number,
path: String,
date: { type: Date, default: Date.now },
dowload: String,
like: Number,
}],
});