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

Removed timestamp from messages

parent f32a2382
No related branches found
No related tags found
No related merge requests found
Pipeline #61497 passed
......@@ -2,14 +2,12 @@ import mongoose from "mongoose";
export interface messageInterface extends Document {
message: String,
time: Date
message: String
}
const messageSchema: mongoose.Schema = new mongoose.Schema({
message: {type: String},
time: new Date()
message: {type: String}
});
const messageModel = mongoose.model<messageInterface>("messages", messageSchema);
......
......@@ -6,24 +6,23 @@ const app = express()
mongoose.connect("mongodb+srv://joasep:koira@messagescluster0.nvb8tqc.mongodb.net/?retryWrites=true&w=majority")
app.get("/", (req, res) => {
res.send("Hello")
})
let messages
addMessage("This is my first message!")
addMessage("This is my message!")
async function addMessage(messageContent){
await Message.create({message: "This is my first message!"})
await Message.create({message: "This is my second message!"})
messages = await Message.find()
console.log(messages);
await mongoose.disconnect()
//await mongoose.disconnect()
}
app.get("/", (req, res) => {
res.send("Hello")
})
const port = process.env.PORT || 3000
app.listen(port)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment