Skip to content
Snippets Groups Projects
Commit c3c08973 authored by Joonas Seppä's avatar Joonas Seppä
Browse files

Adding database

parent 46336825
No related branches found
No related tags found
No related merge requests found
Pipeline #61492 failed
......@@ -21,7 +21,6 @@ deploy-backend-to-heroku:
- gem install dpl
script:
- cd messagesAppBackend
- ls
- dpl --provider=heroku --app=$HEROKU_BACKEND_APP --api-key=$HEROKU_KEY
only:
- master
......
import mongoose from "mongoose"
const messageSchema = new mongoose.Schema({
content: String,
time: new Date()
})
export default mongoose.model("messages", messageSchema)
\ No newline at end of file
import express from 'express'
import mongoose from 'mongoose'
import Message from './Message'
const app = express()
mongoose.connect("mongodb+srv://joasep:koira@messagescluster0.nvb8tqc.mongodb.net/?retryWrites=true&w=majority")
let messages
addMessage("This is my first message!")
async function addMessage(messageContent){
await Message.create({content: messageContent})
messages = await Message.find()
console.log(messages)
await mongoose.disconnect()
}
app.get("/", (req, res) => {
res.send("Now the specific build file isn't specified!")
res.send(messages)
})
const port = process.env.PORT || 3000
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment