123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /**
- * Created by Tony on 2017/3/9.
- */
- var mg = require('mongoose');
- //mg.connect('mongodb://localhost/Demo');
- module.exports = {
- getConnection : function(server, port, dbName) {
- //*/
- if (port) {
- return mg.createConnection(server + ":" + port,dbName);
- } else {
- return mg.createConnection(server,dbName);
- }
- /*/
- if (port) {
- mg.connect('mongodb://' + server + ":" + port + '/' + dbName);
- } else {
- mg.connect('mongodb://' + server + '/' + dbName);
- }
- return mg;
- //*/
- },
- getQAConnection: function(dbName) {
- //*/
- return mg.createConnection("192.168.1.184:60666",dbName);
- /*/
- mg.connect('mongodb://192.168.1.184:60666/' + dbName);
- return mg;
- //*/
- },
- getLocalConnection: function(dbName) {
- //*/
- return mg.createConnection("localhost:27017",dbName);
- /*/
- mg.connect('mongodb://localhost:27017/' + dbName);
- return mg;
- //*/
- },
- getCfgConnection: function(dbName) {
- var config = require("../config.js");
- //*/
- return mg.createConnection(config.current.server + ":" + config.current.port, dbName);
- /*/
- mg.connect('mongodb://' + config.current.server + ":" + config.current.port + '/' + dbName);
- return mg;
- //*/
- }
- };
|