Created
November 18, 2017 16:28
-
-
Save 64lines/cc8c829e1ace855ca0d853c9c4d75548 to your computer and use it in GitHub Desktop.
[NODEJS][MONGOOSE] - Create Schema and Save data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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