Straightforward way to generate code with Mongoose and Node.js and Underscore?

社会主义新天地 提交于 2019-11-27 13:30:50

问题


I want to generate something like this:

http://www.ivarvong.com/2010/08/node-js-connect-mongoose-and-underscore/

But I want to generate the html template and other client-side code, and either have generic/monolithic save/query/reads or generate individualized ones for the Node.js code and the client side (jQuery or whatever), all of that based on the model.

So something like using Underscore to fill in a few templates based on some Monogoose (MongoDB) models. Based on the model you get an HTML form someone can fill in, some client and server-side code to save data in that model to MongoDB, and some code to display the data for that model in a list or table.


回答1:


I've written a library for this. Resource-Juggling takes your JugglingDB models (which may be persisted with Mongoose, Redis, MySQL, or other DBs) and exposes them as RESTful resources. By default we provide JSON access to all of them, but HTML is also possible by just writing the necessary templates.

See https://github.com/bergie/resource-juggling#readme




回答2:


So this is a late reply, but I believe that this is the project you're looking for:

Railway.js

It's kind of a cross between Rails & Node/Express/Mongoose. If you're looking for the Rails of Node.JS, this seems to be the closest thing.




回答3:


Here is another crud gen i found:

https://github.com/jspears/bobamo

I havent personally used it yet, but when i do ill report back




回答4:


Another package you can try is cruds.

It provides crud for node.js, express and mongodb and the REST is compatible with the default backbone.js url scheme.




回答5:


See AllcountJS rapid application development framework. It allows to define domain model in JSON-like format. For example simple Hello World application that would have one MongoDB collection named HelloWorld with two fields: text "Foo" and date "Bar" would look like

A.app({
  appName: "Hello World",
  menuItems: [
    {
      name: "Hello world",
      entityTypeId: "HelloWorld",
    }
  ],
  entities: function(Fields) {
    return {
      HelloWorld: {
        fields: {
          foo: Fields.text("Foo"),
          bar: Fields.date("Bar")
        }
      }
    }
  }
});

Menu, table and form UI is generated automatically using default Jade templates, AngularJS and Twitter Bootstrap. AllcountJS also provides a way to override default templates and has other extension points.




回答6:


I'm not 100% sure I follow but maybe something like Backbone.js would help. Backbone will provide an MVC framework making it very easy to create straightforward consistent components in each layer.



来源:https://stackoverflow.com/questions/4291130/straightforward-way-to-generate-code-with-mongoose-and-node-js-and-underscore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!