Monday, 22 May 2017

mongoose only saves one of several users?

So, I've got this schema:

var FileSchema = new Schema({
    name: String,
    owner: String,
    processed: Boolean
});

module.exports = mongoose.model('UserFile', FileSchema);

that I'm trying to save on a certain function as follows:

var newFile = new UserFile();

  newFile.owner    = decoded.email;
  newFile.name = req.file.originalname;
  newFile.processed = false;

  // save the file
  newFile.save(function(err) {
      if (err)
          throw err;
  });

Yet when I check the database, the document is saved only with the owner and processed fields. The field called name doesn't appear.

If I console.log the variable req.file.originalname , I get the correct result, so it's not null (?). Why is it not saving then?



via kace91

No comments:

Post a Comment