我知道将Ember与Express JS集成在一起说你通常应该对你的模型有两个表示(一个在骨干中,一个在表达中使用mongoose模式),但我想知道是否有某种方法来定义一个模型并将其翻译成动态模型和猫鼬模型。
我真的不想通过两次编写相同的模型在代码中重复自己。
I know Integrating Ember with Express JS says that you generally should have two representations of your models (one in backbone, one in express using mongoose schema), but I was wondering if there is some way to define a model once and have it translated into an ember model and a mongoose model on the fly.
I really don't want to repeat myself in code by writing the same model twice.
最满意答案
你可以做到这一点的唯一方法是建立一个发电机。 我目前正在研究使用noeo4js作为后端,你可以阅读ember模型,根据其信息生成它,或者根据你的后端模型生成一个ember模型,或者生成两个描述符json对象。
The only way that you can do this is by building a generator. I am currently looking into this using noeo4js as the back end, you can either read the ember model, and generate it based on its information or generate a ember model based on your backend's model, or generate both of a descriptor json object.
更多推荐
发布评论