0

I am writing an application using yeoman angular-fullstack, I defined some entities that I would like to access from other entities controller. For example I have in my server->api->Mall I have the following code:

var MallSchema = new Schema({
  ...
});

module.exports = mongoose.model('Mall', MallSchema);

in other Business controller I would like to search for Mall by _id, using mongoose, But I can not import MallSchema trying to do the following:

mall = mongoose.models("MallSchema").find({_id: "some_mall_id"})
business.mallType = mall.type
business.update();

or nesting Schema's

var MallSchema = new Schema({
  business : Business;
});

I really tried in lot of ways, ending up with frustration, googling this yields lots of answers, none have works and few just seems too complicated like this one, I newbie to node.js so I mast been missing somthing simple. any help would be nice for the entire community.

moshe beeri
  • 2,007
  • 1
  • 17
  • 25

1 Answers1

0

it seems simple but somehow missed from documentation this seems to work for me now

var business = require('../business/business.model')();
var user = require('../user/user.model')()

Hope it helps.

moshe beeri
  • 2,007
  • 1
  • 17
  • 25