Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Jero786
Created June 13, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jero786/ce4a81168b349ac44c01be8c9f21ca0f to your computer and use it in GitHub Desktop.
Save Jero786/ce4a81168b349ac44c01be8c9f21ca0f to your computer and use it in GitHub Desktop.
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: 'jero.carrizo@gmail.com',
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