How can I share mongoose models between 2 apps?

后端 未结 6 515
不思量自难忘°
不思量自难忘° 2021-02-04 06:26

I have 2 apps, each in a different folder and they need to share the same models.

I want to symlink the models folder from app A to a models folder in app B.

I\'

6条回答
  •  感情败类
    2021-02-04 06:39

    ./shared/models/user.js
    
    ./app1/app.js
    var user = require('../shared/user.js');
    
    ./app2/app.js
    var user = require('../shared/user.js');
    

    I dont' see why you couldn't just load the models from a shared path.

提交回复
热议问题