-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0165833
Showing
10 changed files
with
1,586 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let mongoose = require('mongoose'); | ||
mongoose.connect('mongodb+srv://Hitesh:MITohnasan@[email protected]/messenger?retryWrites=true&w=majority', { useNewUrlParser: true, useUnifiedTopology: true }) | ||
.then(() => { console.log("connection established with mongodb server online"); }) | ||
.catch(err => { | ||
console.log("error while connection", err) | ||
}); | ||
|
||
module.exports = {mongoose} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { mongoose } = require('../Connectors/mongoose'); | ||
|
||
// const Schema = | ||
const messageThreadSchema = new mongoose.Schema({ | ||
// threadId: String | ||
threadId: { type: String, unique: true }, | ||
messageArray: [{ | ||
time: { type: Date, default: Date.now }, | ||
sender: String, | ||
receiver: String, | ||
seen: { type: Boolean, default: false }, | ||
received: { type: Boolean, default: false }, | ||
deleted: { type: Boolean, default: false }, | ||
message: String | ||
}] | ||
|
||
}) | ||
|
||
module.export = { mongoose, messageThreadSchema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// const { mongoose, messageThreadSchema } = require("./Schema/messageThreadSchema") | ||
// Schemas are compiled to Model, A model is a class with which we construct documents. | ||
const { mongoose } = require('./Connectors/mongoose'); | ||
|
||
|
||
const messageThreadSchema = new mongoose.Schema({ | ||
// threadId: String | ||
threadId: { type: String, unique: true }, | ||
messageArray: [{ | ||
time: { type: Date, default: Date.now }, | ||
sender: String, | ||
receiver: String, | ||
seen: { type: Boolean, default: false }, | ||
received: { type: Boolean, default: false }, | ||
deleted: { type: Boolean, default: false }, | ||
message: String | ||
}] | ||
|
||
}) | ||
|
||
|
||
const messageThreadModel = mongoose.model('newTag', messageThreadSchema); | ||
|
||
|
||
|
||
const sendMessage = (details) => { | ||
console.log(details) | ||
let newMessage = new messageThreadModel({ | ||
threadId: details.threadId, | ||
messageArray: [ | ||
{ | ||
time: details.date || (new Date).toUTCString(), | ||
sender: details.sender, | ||
receiver: details.receiver, | ||
message: details.message | ||
} | ||
] | ||
}) | ||
console.log(newMessage) | ||
newMessage.save((err) => { | ||
if (err) { | ||
console.log("Error in sending the message!", err) | ||
return false | ||
} | ||
else { | ||
|
||
return true | ||
} | ||
}) | ||
} | ||
|
||
|
||
|
||
module.exports = { sendMessage }; | ||
|
||
|
Submodule client
added at
563c12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const createMessageThread = (data) => { | ||
return "HiteshDinesh" | ||
} | ||
|
||
module.exports = { createMessageThread } |
Oops, something went wrong.