如何在两个应用程序之间分享猫头鹰模型? [英] How can I share mongoose models between 2 apps?
问题描述
我想将模型文件夹从应用程序A符号链接到模型文件夹在应用程序B中。
我遇到了一个问题,一旦你在应用程序A中调用mongoose.model('Model',Schema)有没有人有任何提示来管理这个最好的方法?
我最后在这里做的是将app1作为子模块(使用Git)导入app2。这样,模型可以正常导入,并与应用程序的默认 mongoose
连接相关。
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'm running into issues with the fact that once you call mongoose.model('Model', Schema) in app A, they are 'tied' to that app's mongoose/mongodb connection.
Does anyone have any tips on the best way to manage this?
What I ended up doing here was importing app1 as a submodule (with Git) in app2. This way the models can be imported as normal and are tied to the app's default mongoose
connection.
这篇关于如何在两个应用程序之间分享猫头鹰模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!