问题标签 [compoundjs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
303 浏览

node.js - NodeJS+CompoundJS 中的助手

我刚刚开始使用 CompoundJs,还有很多东西需要学习。

我只是想弄清楚 Helpers 在 NodeJS+CompoundJS 中是如何工作的,从我目前看到的情况来看,Helper 旨在与 Views 一起使用,而不是与 Controllers 一起使用。但是,我想创建一个简单的函数来验证参数中给出的用户输入(检查是否定义了某些参数,并可选择检查它们的值是否有效)。谁能向我解释实现这一点的最佳方法是什么?请记住,我希望在许多不同的控制器中使用它,因此它应该是全局可用的。我必须使用自定义验证器或助手吗?

0 投票
1 回答
1029 浏览

windows - 在 Windows 上使用复合 js。无法启动任何东西

我希望使用 Compound.js 创建一个 hello world 应用程序
到目前为止,根本没有任何效果。
我已经安装了“npm install Compound -g”来让 Compound 在全球范围内可用。
现在我想运行“compound init”,我得到了这个:

(见第一个代码块)

在谷歌搜索时,我在 npm 上找到了一个名为mongoose-compound-example-app 的示例应用程序
在 npm 安装之后,我运行了“node”。正如自述文件中所建议的:

(参见第二个代码块)
我使用的是 Windows 8 x64。Node 本身可以工作,而且我已经能够使用locomotive.js运行“hello world”应用程序。我真的很想弄明白化合物并开始工作,但我似乎什么也做不到。

先感谢您!

编辑:我正在使用节点 v0.10.0

猫鼬复合示例应用程序错误:

0 投票
1 回答
104 浏览

compoundjs - 我们如何为我们的 shema “compoudjs / jungglingdb”添加约束

我是初学者,我开始使用compoudjs,我使用jungglingdb 作为数据库和模块jungglung-postgres。我的问题是,如何向创建的表添加约束?我试试这个 var User = describe('User', function () { property('firstname', String); property('lastname', String); property('password', String,{ limit: 50); property( 'email', String {unique:true}); property('approved', Boolean); set('restPath', pathTo.users); }); 但它不工作

请帮忙。坦克

0 投票
0 回答
456 浏览

jquery - Coffeescript & ejs 如何从数组中为每 x 个项目添加 html

我正在使用 nodeJs .. 我有以下 javascript .. 从我的数据库中迭代一系列项目。我在做这个服务器端,这样数据是预先排序的,当使用把手时,我所要做的就是一个简单的嵌套每个语句..

这是从我使用geddy的时候开始的..

我已经把上面的js翻译成了coffeescript..

话虽如此,我有以下咖啡脚本 ajax 请求:

我试图在第三次迭代之后插入一些额外的 HTML 以完成以下操作:

在此处输入图像描述

构成上述屏幕截图的 html 是这样的,它的引导程序 2.3:

组织数组控制器端,传递给render方法然后让ejs只做两个嵌套循环,使用jquery和ajax请求注入或其他方法会更有益吗?

0 投票
2 回答
1108 浏览

node.js - Node js,使用connect-memcached时没有返回响应

嗨,我正在使用 Compoundjs 和 connect-memcached。以下是我的 envirionment.js 文件中的内容:

当我通过给出以下命令启动服务器时:

它开始很好,我得到:

当我通过浏览器请求时,我没有得到任何响应。

以下是我的 routes.js 文件内容:

在我的名字控制器中:

PS:如果我评论使用 connect-memcached 和通过浏览器请求的代码,我会得到响应。

提前感谢您的帮助。

0 投票
1 回答
664 浏览

node.js - 在 node.js 中自定义验证消息

我是 Node.js 的新手,在 node.js 中自定义验证消息时遇到了问题。我使用 CRUD 操作使用 Compound JS 创建了一个简单的应用程序。在我的应用程序中有一个名为“id”的字段。“id”字段只接受整数值。然后我使用 model/user.js 中的以下代码验证该字段。

通过使用上面的代码,它工作正常。但我也想检查该字段是否为空白。然后我稍微修改一下代码。修改后的代码如下所示:

然后,如果该字段为空,则验证消息将显示为“Id 不能为空”。但是,当我在 id 字段中输入数字以外的值时,验证错误消息将是“Id [object Object]”。我认为关键字 with 不受支持。这里是否有任何其他关键字,如“空白”或“分钟”,以便我可以将验证消息作为“ID 不是数字”。

我找到了一个解决方案,所以修改后的 user.js 版本是这样的:

上面代码的问题是它同时显示两条验证消息,即同时显示默认和自定义空白消息。我的要求是一次只显示一个字段的验证消息。这可能吗?

0 投票
1 回答
329 浏览

node.js - 使用 Compound.js 更新控制器中的属性

我尝试使用 Compound.js 创建博客。我有两个表格,“类别”和“发布”,每个表格都有日期属性,但是当我生成表格时,我得到了一个表格,每个“新”视图中都有一个日期属性的输入......

我想在创建它时在我的控制器中自动更新日期属性。

我该怎么做?

我的谢玛:

我的模型:

我的控制器:

0 投票
1 回答
352 浏览

javascript - Trying to define an asset compiler in Compoundjs and getting undefined method error

I'm trying to define an asset compiler according to the documentationhttp://compoundjs.com/docs/#asset-compiler-adding-your-own-compiler, however, I keep getting an error:

My entire environment.js file looks like:

I tried a console.log(compound.assetsCompiler); just before the app.use(compount.assetsCompiler... statement and sure enough I get undefined. The documentation also says to use compound.assetCompiler.add(...); (singular asset) which I assume is a typo but since it got that typo wrong multiple times I tried it as well but had the same problem. Does anyone have any idea how to fix this?

0 投票
1 回答
292 浏览

node.js - 使用复合,使用 validatesPresenceOf 时出现更新错误

我正在使用 Compound 和 mongodb 创建一个应用程序。复合使用jugglingdb和jugglingdb-mongodb连接mongodb。

我使用化合物的脚手架为客户生成了一个 crud。然后,我添加Client.validatesPresenceOf('name');到 app/models/client.js

在创建时,它可以工作,但在更新时它会失败。

我也尝试将验证添加到 db/schema.js,但我得到了同样的错误。

这是我得到的错误

/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:529 抛出错误;^ 错误:发送后无法设置标题。在 ServerResponse.OutgoingMessage.setHeader (http.js:708:11) 在 ServerResponse.res.setHeader (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/node_modules/connect/lib/patch.js:59 :22) 在 ServerResponse.res.location (/Users) 的 ServerResponse.res.set.res.header (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/lib/response.js:518:10) /camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/lib/response.js:649:8) 在 ServerResponse.res.redirect (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/lib /response.js:691:ModelConstructor 的代码(在 (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/compound/node_modules/kontroller/lib/base.js:157:17), :84:9) 进行评估。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/model.js:827:33) 在 ModelConstructor.next (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/ lib/hooks.js:48:18) 在 ModelConstructor。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/model.js:826:38) 在 ModelConstructor.next (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/ lib/hooks.js:48:18) 在 /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/model.js:825:30 在 /Users/camilo/Documents/Pruebas/Nodejs/interno2 /node_modules/jugglingdb-mongodb/lib/mongodb.js:249:9 在 /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/collection.js:703:14 处为空。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/db.js:1709:18) 在 EventEmitter 的 g (events.js:175:14)。在 Server.Base._callHandler (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/base.js: 130:25) 在 /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:464:24 在 MongoReply.parseBody (/Users/camilo /Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:132:5) 无效。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:410:22) 在 EventEmitter.emit (events.js:95:17 ) 为空。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:190:13) 在 EventEmitter.emit (events.js:98:17 ) 在套接字。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/connection.js:382:22) 在 Socket.EventEmitter.emit (events.js:95 :17) 在套接字。(_stream_readable.js:699:14) 在 Socket.EventEmitter.emit (events.js:92:17) 在 emitReadable_ (_stream_readable.js:382:10) 在 emitReadable (_stream_readable.js:377:

版本:

  • 节点:0.10.1
  • 复合js:1.1.5-21
  • jubblingdb: 0.2.0-27
  • jugglingdb-mongodb: 0.0.4-1
0 投票
1 回答
217 浏览

node.js - 复合js应用程序的npm测试

我有一个复合 js 应用程序。我只使用生成脚手架

复合g脚手架用户名姓

该命令还创建了 test/controllers/users-controllers-test.js 文件。我曾尝试将此测试作为“npm 测试”运行。

但在 Windows 上,它给出的错误是“ Error: ENOENT, stat '.........\test\*\*'

在 linux/centos 上,它给出了一个类似“ReferenceError: describe is not defined”的错误

请帮助我了解我到底错过了什么......

请尽快提出要求,因为它阻碍了我的工作。

在此先感谢,等待肯定的答案,

谢谢