Skip to content
Snippets Groups Projects
Commit 0e992714 authored by Viivi Nevalainen's avatar Viivi Nevalainen
Browse files

Upload New File

parent a925b004
No related branches found
No related tags found
No related merge requests found
const mongoose = require('mongoose')
if (process.argv.length<3) {
console.log('give password as argument')
process.exit(1)
}
const password = process.argv[2]
const mongoUrl =
`mongodb+srv://part3:${password}@cluster0.2mcuqe5.mongodb.net/blogApp?retryWrites=true&w=majority`
mongoose.connect(mongoUrl)
const blogSchema = new mongoose.Schema({
title: String,
author: String,
url: String,
likes: Number
})
const Blog = mongoose.model('Blog', blogSchema)
const blog = new Blog({
title: "Summer vacation",
author: "Rosa Sparks",
url: "www.myblog.blogspot.com",
likes: 331
})
blog.save().then(result => {
console.log('blog saved!')
mongoose.connection.close()
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment