Search code examples
node.jsmongodbmean-stackmongoose-schema

How to save a file in mongoose


I want to save a file using node JS to save a file in an attribute using mongoose schema to save an entry in mongoose collection.

What should be the type of the attribute in the schema?
And how can I save the file to this attribute?

I used the regular save function, but it saved all the attributes posted by the router except this one attribute of the image


Solution

  • You should not save a file in mongoose, instead you should upload the file, and save the path to the file in mongoose, for this you will just need a string field to save the path