add connection
This commit is contained in:
parent
68f48b0c09
commit
374e000f5b
1 changed files with 10 additions and 2 deletions
|
|
@ -1,4 +1,12 @@
|
||||||
const mongoose = require("mongoose")
|
const config = require('../config');
|
||||||
|
const mongoose = require( 'mongoose' );
|
||||||
|
const url = config.mongodbHost+config.mongodbDatabase;
|
||||||
|
|
||||||
|
mongoose.connect(url,({useNewUrlParser: true, useUnifiedTopology: true})).then( function(){
|
||||||
|
console.log('mongodb-privated-room connected '+mongoose.connection.readyState);
|
||||||
|
}).catch(function(err){
|
||||||
|
console.log('error : '+err);
|
||||||
|
});
|
||||||
|
|
||||||
const MessageSchema = new mongoose.Schema(
|
const MessageSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
|
|
@ -18,4 +26,4 @@ const MessageSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
module.exports = mongoose.model("PrivatedMessage", MessageSchema);
|
module.exports = mongoose.model(config.mongodbPrivatedMessages, MessageSchema);
|
||||||
Reference in a new issue