const mongoose = require('mongoose')
class MgDbFactory {
  constructor() {
    const reqUrl = "mongodb://wdy1:123456@43.247.184.94:27017/phones";
    this.mgdb = mongoose.connect(reqUrl, { useNewUrlParser: true });
  }

  getModel(tabName) {
    // let schema = require("./model/" + tabName.replace(/_/g, "."));
    let model = mongoose.models[tabName];
    if (!model) {
      model = mongoose.model(tabName, new mongoose.Schema({
        company_name: { type: String }
      }), tabName);
    }
    return model
  }
}
module.exports = MgDbFactory;