Tag: 复合

在脚手架复合js的路线中拼写错误问题

我是新的节点和复合。 当我试图脚手架 compound g crud leaveApplication leave_code:string description:string applicable:string carry_forward:boolean limit_type:boolean lop:boolean od:boolean co:boolean leave_revision:boolean active:boolean 我得到一些错误,然后我尝试了 compound g crud leave code:string description:string applicable:string cForward:boolean limit:boolean lop:boolean od:boolean co:boolean leave_revision:boolean active:boolean 但现在发生的错误是以路线的名义 leaves GET /leaves.:format? leaves#index leaves POST /leaves.:format? leaves#create new_leafe GET /leaves/new.:format? leaves#new edit_leafe GET /leaves/:id/edit.:format? leaves#edit leafe DELETE /leaves/:id.:format? leaves#destroy leafe PUT /leaves/:id.:format? […]

在node.js中定制validation消息

我是Node.js的新手,并且在node.js.中定制validation消息时遇到了问题。我使用CRUD操作创build了一个使用Compound JS的简单应用程序。 在我的应用程序中有一个名为“ID”的字段。 “id”字段只接受整数值。 然后我通过在model / user.js中使用以下代码来validation该字段。 module.exports = function (compound, User) { var num = /^\s*\d+\s*$/; User.validatesFormatOf('id', {with: num, message:"is not a number"}); }; 通过使用上面的代码,它工作正常。 但是我也想检查一下这个字段是否为空。 然后我稍微改变一下代码。 修改后的代码如下所示: module.exports = function (compound, User) { var num = /^\s*\d+\s*$/; User.validatesFormatOf('id', {with: num, message: {blank: "can't be blank", with: "is not a number"}}); }; 然后validation消息,如果该字段为空,将显示为“Id不能为空”。 但是,当我input除数字以外的id字段中的值时,validation错误消息将是“Id […]

“describe”和“schema.define”有什么区别?

当我通过CompoundJS的世界取得进展时,我遇到了两种定义模式的方法: 第一: var Product = describe('Product', function () { property('upc', String); property('name', String); set('restPath', pathTo.products); }); 第二: var Schema = require('jugglingdb').Schema; var schema = new Schema('memory'); var Product = schema.define('Product', { upc: { type: Number, index: true }, name: { type: String, limit: 150, index: true }, createdAt: { type: Date, default: Date.now }, modifiedAt: […]

复合服务器8888失败,“连接失败”

我想在windows机器上用nodejs启动一个项目。 我知道窗户不是正确的环境,但这就是我使用的! 我用compound server 8888启动我的服务器时遇到错误。 我通过生成所有文件 compound init photo –tpl jade –css less –db mongodb cd photo npm install -l compound generate crud album title images createdAt:date 当我意识到你可以安装化合物作为复合或复合js ,这一代运行良好(复合js安装它没有工作,但是当我安装复合它的工作 – 我认为这是相同的: – /)。 但是,当我尝试启动服务器与compound server 8888它打破了这个错误: 在开发环境中在0.0.0.0:8888上侦听的复合服务器 {PATH} \照片\ node_modules \ jugglingdb-mongodb的\ lib中\ mongodb.js:74 如果(犯错)抛出犯错; ^ 错误:无法连接到[localhost:27017] 在Server.connect.connectionPool.on.server._serverState({PATH} \ photo \ node_modules \ jugglingdb-mongodb \ […]

为什么一些基于Express的node.js web框架被构build? 为什么Express不执行这些function?

我是node.js techique栈的新手。 我发现有很多文章介绍node.js和Express。 我知道Express是一个很好的Web框架,包括模板引擎,路由等。它是stream行的,活跃的框架。 有一点我很困惑: 为什么仍然有这么多的Web框架构build在Express上? 缺less多lessfunction? 为什么Express不会发展添加更多function? 它是一个较低级别的Web框架吗? Express和其他产品(基于Express构build)的产品定位是什么?

如何处理compoundjs中不同命名空间的单独布局

嘿家伙,我是一个刚刚开始在nodejs工作的noob。 我正在开发一个使用复合jj的nodejs上的web应用程序。 这是我的视图文件夹的结构 views/ |– admin | |– games | |– squadplayertypes | `– toursection | |– tourformats | |– tourmatchtypes | `– tours |– layouts | |– admin | | `– toursection 我创build了一个名称空间来处理所有针对“/ admin”的请求。 现在我想知道是否有可以在命名空间“admin”中为所有路由定义通用布局的地方。 这是我写我的routes.js admin.namespace('toursection', function(toursection){ toursection.resources('tours',function(tour){ tour.post('fetchTourDetails','tours#fetchTourDetails',{collection:true}); }); toursection.resources('tourmatchtypes'); toursection.resources('tourformats'); }); /*Routes for squad players and all related dependancies*/ admin.resources('squadplayers');

复合JS关系访问

我已经定义了2个模式对象如下(用于一个mongodb) var User = describe('User', function () { property('name', String); property('email', String); property('password', String); set('restPath', pathTo.users); }); var Message = describe('Message', function () { property('userId', String, { index : true }); property('content', String); property('timesent', Date, { default : Date }); property('channelid', String); set('restPath', pathTo.messages); }); Message.belongsTo(User, {as: 'author', foreignKey: 'userId'}); User.hasMany(Message, {as: 'messages', foreignKey: 'userId'}); […]

如何通过CompoundJS中的“使用”方法传递参数?

我正在使用CompoundJS(Express / NodeJS的MVC)。 为了在控制器之间共享代码,Doc说在controller1.js我可以使用publish方法来共享一个方法: /***controller1.js***/ function sharedFunction () {…} publish('sharedFunction', sharedFunction); //Sharing… 在controller2.js我可以通过load它并尝试use方法来访问它: /***controller2.js***/ load('controller1'); // _controller siffix must be omitted use('sharedFunction') 问题 这很好,但是,我有一个sharedFunction有params: /***controller1.js***/ function sharedFunction (param1, param2) {…} publish('sharedFunction', sharedFunction); //Sharing… 我一直在阅读文档,但是我找不到如何,或者语法,在controller1.js上的use方法上添加这个参数。 我在哪里发送这些参数? : /***controller2.js***/ load('controller1'); // _controller siffix must be omitted use('sharedFunction(params here?)', {params here?}) //where do I send the params? 非常感谢你!

如何在jugglingdb中添加一个自定义属性来build模,并通过JSON返回

如何将一个自定义属性添加到jugglingdb模型? 我想定义一个自定义的属性,特别是与自定义的方法,因为我想把它返回给客户端。 这是一个使用无处不在的Post模型的例子: DB / schema.js: var Post = schema.define('Post', { title: { type: String, length: 255 }, content: { type: Schema.Text }, date: { type: Date, default: function () { return new Date;} }, timestamp: { type: Number, default: Date.now }, published: { type: Boolean, default: false, index: true } }); 应用程序/模型/ post.js: var […]

复合jslogging用户的行为

我需要find一种方法在我的Compound.JS + MongoDB应用程序中logging用户的活动。 创build一个表并插入信息,比如who(什么login名)更新/创build/删除哪个表中的哪个logging,哪个字段从哪个字段改变到哪个字段,这将是非常好的。 我认为这可能是一个npm包,但到目前为止在谷歌我只find有关日志logging(写入日志文件)这是不是我想要的。