javascript - Can 't get a working Express Mongoose connection -


despite many topics (queries hang when using mongoose.createconnection() vs mongoose.connect() , unfortunataly lack of experience can 't working connection mongoose.createconnection.

inspired on 1 of mentioned linked started change script without result.

//my db.js    const mongoose = require('mongoose'), db;    db = mongoose.createconnection = ("mongodb://localhost:27017/myapp",  { "auth": { "authsource": "admin" }, "user": "admin1234", "pass": "abcd" });     require('./profiles');    //profiles.js    const mongoose = require('mongoose');    const logfile = new mongoose.schema ({});  //etc etc    mongoose.model('profile', profileschema);    // routepages index.js    const express = require('express')';  const router = express.router();  const ctrlprofiles('../controller/profiles');    router  //some routes     module.exports = router;      //controllers profiles.js  const mongoose = require('db'),    const prof = mongoose.model('profile');    const profilecreate = function (req,res) {};    module.exports = {  profilecreate   };

your first line may break script!

const mongoose = require('mongoose'), db; 

try

const mongoose = require('mongoose'); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -