Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

GridFs Schema

//define Model for metadata collection.
var GFS = mongoose.model("GFS", new Schema({}, {strict: false}), "fs.files" );

var UserSchema = Schema({
    image: {type: Schema.Types.Object, ref: 'GFS' } // refer the model
});

var User = mongoose.model('User', UserSchema);

User.findById(req.params.id)
  .populate('image') //populate 
  .exec(function(err, user) {...})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #GridFs #Schema
ADD COMMENT
Topic
Name
4+8 =