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

Adding Message interface for mongoose

parent c3c08973
No related branches found
No related tags found
No related merge requests found
import mongoose from "mongoose" import mongoose from "mongoose";
const messageSchema = new mongoose.Schema({
content: String,
time: new Date()
})
export default mongoose.model("messages", messageSchema) export interface messageInterface extends Document {
\ No newline at end of file message: String
}
const messageSchema: mongoose.Schema = new mongoose.Schema({
message: {type: String}
});
const messageModel = mongoose.model<messageInterface>("messages", messageSchema);
export default messageModel;
\ No newline at end of file
...@@ -6,6 +6,7 @@ const app = express() ...@@ -6,6 +6,7 @@ const app = express()
mongoose.connect("mongodb+srv://joasep:koira@messagescluster0.nvb8tqc.mongodb.net/?retryWrites=true&w=majority") mongoose.connect("mongodb+srv://joasep:koira@messagescluster0.nvb8tqc.mongodb.net/?retryWrites=true&w=majority")
/*
let messages let messages
addMessage("This is my first message!") addMessage("This is my first message!")
...@@ -19,13 +20,14 @@ async function addMessage(messageContent){ ...@@ -19,13 +20,14 @@ async function addMessage(messageContent){
await mongoose.disconnect() await mongoose.disconnect()
} }
*/
app.get("/", (req, res) => { app.get("/", (req, res) => {
res.send(messages) res.send("Hello")
}) })
const port = process.env.PORT || 3000 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