Skip to content

Instantly share code, notes, and snippets.

@64lines
Created November 18, 2017 16:28
Show Gist options
  • Save 64lines/cc8c829e1ace855ca0d853c9c4d75548 to your computer and use it in GitHub Desktop.
Save 64lines/cc8c829e1ace855ca0d853c9c4d75548 to your computer and use it in GitHub Desktop.
[NODEJS][MONGOOSE] - Create Schema and Save data
var mongoose = require('mongoose');
var Schema = new mongoose.Schema({
filename: String,
path: String,
creationDate: Date
});
var Image = mongoose.model('Image', Schema);
var newImage = new Image({filename: "hi.jpg", path:"/some/path", creationDate: new Date()})
newImage.save(function(err) {
if (err) console.log(err);
console.log("Saved!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment