我正在用复合和mongodb创建一个应用程序。复合使用jugglingdb和jugglingdb-mongodb连接到mongodb。
我用化合物的脚手架为客户生成了一个crud。然后,我将Client.validatesPresenceOf('name');添加到app/model/client.js中。
module.exports = function (compound, Client) {
Client.validatesPresenceOf('name');
};在创建时,它可以工作,但是在更新时它会失败。
我还尝试将验证添加到db/schema.js,但得到了相同的错误。
这就是我所犯的错误
/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:529抛出错误;^ Error:无法在发送后设置标头。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/node_modules/connect/lib/patch.js:59:22) at ServerResponse.res.set.res.header (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/lib/response.js:518:10) at ServerResponse.res.location (/User/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/lib/response.js:649:8) at ServerResponse.res.redirect (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/express/lib/response.js:691:8) at Controller.Helpers.redirect (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/compound/node_modules/kontroller/lib/helpers.js:168:14) at Controller.Helpers.redirect at (/Users/camilo )/Documents/Pruebas/Nodejs/interno2/node_modules/compound/node_modules/kontroller/lib/base.js:157:17),:97:38)在(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/compound/node_modules/kontroller/lib/helpers.js:43:17)的Object.html:93:20)在(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/compound/node_modules/kontroller/lib/helpers.js:38:5) at action.cliente.destroy.format.json.send.code ( (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/compound/node_modules/kontroller/lib/base.js:157:17),:84:9)在ModelConstructor。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/model.js:827:33) at ModelConstructor.next (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/hooks.js:48:18) at ModelConstructor.(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/model.js:826:38) at ModelConstructor.next (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/hooks.js:48:18) at /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb/lib/model.js:825:30 at /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/lib/mongodb.js:249:9 at /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/collection.js:703:14为null。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/db.js:1709:18) at g (events.js:175:14) at EventEmitter.emit (events.js:106:17) at Server.Base._callHandler (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/base.js:130:25) at /Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:464:24 at MongoReply.parseBody (/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:132:5) at null。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/server.js:410:22) at EventEmitter.emit (events.js:95:17)为null。(/Users/camilo/Documents/Pruebas/Nodejs/interno2/node_modules/jugglingdb-mongodb/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:190:13) at 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) at Socket.EventEmitter.emit (events.js:95:17)在套接字处。(_stream_readable.js:699:14)在Socket.EventEmitter.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:382:10) at emitReadable (_stream_readable.js:377:5) at readableAddChunk (_stream_readable.js:142:7) at Socket.Readable.push (_stream_readable.js:112:10) at TCP.onread (net.js:511:21)
版本:
发布于 2013-04-01 16:55:36
这个问题是jubblingdb 0.2.0-27上的一个bug。作者将其更新为0.2.028,解决了问题。
https://stackoverflow.com/questions/15736954
复制相似问题