خرید بک لینک

Vote count: 0

I have two databases that one affects the other one, so I wanted to see if there was a way to coect two both dbs so that one model can be associated to the other db where the other model can focus on a diff db.

Currently my models look like this:

var mongoose, Schema, Moduser, ObjectId, Project, bcrypt, SALT_WORK_FACTOR;
mongoose = require('mongoose');
Schema = mongoose.Schema;
ObjectId = mongoose.Schema.Types.ObjectId;
Project = require('../models/project.js');
bcrypt = require('bcryptjs');
SALT_WORK_FACTOR = 10;



Moduser = new Schema({
    email: { type: String, required: true, lowercase: true, index: {unique: true}},
    password: { type: String, unique: true}

}, {collection: "modusers"});

module.exports = mongoose.model('Moduser', Moduser);

and in my routes I call mongoose like so up top:

var mongoose = require('mongoose');
mongoose.coect("mongodb://coect1");

I want to be able to use in my routes file a function that can make use of both dbs... how do I add a second db and then target both dbs specifically - I was thinking maybe including them in the models, but was not sure how to implement it like so?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 13 خرداد 1395 ساعت: 12:32

صفحه بندی