You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
858 B
JavaScript

const mongoose = require('mongoose')
mongoose.Promise = Promise
const models = {
Sock: require('./sock.js').schema,
Media: require('./media.js').schema,
User: require('./user.js').schema,
Cart: require('./cart.js').schema,
Coupon: require('./coupon.js').schema,
}
module.exports = function connect(url) {
const connection = mongoose.createConnection(url)
connection.on('error', console.error.bind(console, 'connection error:'));
var sock = connection.model('Sock',models.Sock, 'socks');
var media = connection.model('Media',models.Media, 'medias');
var user = connection.model('User',models.User, 'users');
var cart = connection.model('Cart',models.Cart, 'carts');
var coupon = connection.model('Coupon',models.Coupon, 'coupons');
return {
sock,
media,
user,
cart,
coupon,
_connection: connection
}
}