我正在使用快递js,mongoose和ember js。(I'm using express js, mongoose, and ember js. Is there a way to wr

编程入门 行业动态 更新时间:2024-10-28 19:23:08
我正在使用快递js,mongoose和ember js。(I'm using express js, mongoose, and ember js. Is there a way to write models only once?)

我知道将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.

更多推荐

本文发布于:2023-07-15 18:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117463.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:快递   mongoose   js   ember   write

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!