Straightforward way to generate code with Mongoose

2019-01-22 17:42发布

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.

6条回答
beautiful°
2楼-- · 2019-01-22 18:19

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楼-- · 2019-01-22 18:19

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.

查看更多
干净又极端
4楼-- · 2019-01-22 18:26

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

查看更多
何必那么认真
5楼-- · 2019-01-22 18:30

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

查看更多
该账号已被封号
6楼-- · 2019-01-22 18:30

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.

查看更多
Rolldiameter
7楼-- · 2019-01-22 18:41

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.

查看更多
登录 后发表回答