@8bittitan/norse 中文文档教程
Norse
用于使用 Mongoose 作为 ORM 构建节点应用程序的 CLI。
Inspiration
此 CLI 在很大程度上基于 Ruby on Rails 的 rails
CLI。
API
norse model [modelName] [...fields]
创建一个名为 modelName
的新模型(norse model Post
创建 Post.js)。
norse model Post field:type
创建一个 Post
模型,其中 field
作为文档属性,type
作为属性类型(字符串、布尔值等)。 默认情况下,如果未指定,该字段将具有 String
类型。
norse controller [controllerName]
创建一个名为 controllerName
Controller 的新控制器(norse controller post
创建 postController.js)。
norse controller post create update
使用 create()
和 update()
方法创建一个 postController
。 默认情况下,index
、create
、show
、update
和 destroy
都会被创建。
norse scaffold [modelName] [..fields]
根据提供的 modelName
和提供的 fields
创建模型和控制器。 默认添加来自控制器命令的默认方法。
norse scaffold Post title description published_at:Date
将使用提供的字段创建 Post
模型,并使用默认方法创建 postController
的控制器。
Norse
A CLI for scaffolding a node application with Mongoose as the ORM.
Inspiration
This CLI is heavily based on the rails
CLI from Ruby on Rails.
API
norse model [modelName] [...fields]
Creates a new model with modelName
as the name (norse model Post
creates Post.js).
norse model Post field:type
Creates a Post
model with field
as the document attribute and type
as the attribute type (String, Boolean, etc…). By default the field will have type String
if not specified.
norse controller [controllerName]
Creates a new controller with the name being controllerName
Controller (norse controller post
creates postController.js).
norse controller post create update
Creates a postController
with the methods of create()
and update()
. By default index
, create
, show
, update
and destroy
are all created.
norse scaffold [modelName] [..fields]
Creates both a model and controller based on the modelName
provided and fields
provided. The default methods from controller command are added by default.
norse scaffold Post title description published_at:Date
Will create a model of Post
with supplied fields and the controller of postController
with default methods.