Tuesday, 23 May 2017

How do I use mongoose models from my main app folder on another folder?

I found many examples, but I'm still quite confused on how to share one mongoose model in another folder. For example, let say I have a main folder and two subfolders. I want to share my App folder's mongoose model from app folder on admin folder, because these two folders will share the same mongodb Database

enter image description here

app folder's models

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const OrderSchema = new Schema({
  product: String
  created: { type: Date, default: Date.now },
});

module.exports = mongoose.model('Order', OrderSchema);

Any efficient way to share?



via sinusGob

No comments:

Post a Comment