Created
June 13, 2019 15:23
-
-
Save Jero786/ce4a81168b349ac44c01be8c9f21ca0f to your computer and use it in GitHub Desktop.
This file contains 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
const express = require('express'); | |
const mongoose = require('mongoose'); | |
mongoose.connect('mongodb://localhost/demo', {useNewUrlParser: true}) | |
.then(() => console.log('Connection successfull')) | |
.catch(err => console.error(err)); | |
const BlogSchema = mongoose.Schema({ | |
name:String, | |
email:String, | |
mobile:Number, | |
message:String | |
}, { | |
strict: false | |
}); | |
const BlogModel = mongoose.model('Blog', BlogSchema); | |
const brisaBlog = new BlogModel({ | |
name: 'brisa', | |
email: '[email protected]', | |
mobile: 123, | |
message: 'Some interesting message here' | |
}); | |
brisaBlog.save((err, res) => { | |
if (err) { | |
console.log('ERROR ' + err); | |
} else { | |
console.log('SUCESSS' + res); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment