Tag: js jugglingdb

“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: […]

复合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'}); […]

如何在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 […]

Compoundjs无法与jugglingdb-mysql一起运行

试图用mysqltestingcompoundjs,但是失败了。 我的系统是Debian 7,具有以下版本的nodejs&npm $ node -v v0.10.13 $ npm -v 1.3.4 这是我如何安装compoundjs sudo npm install -g复合 sudo npm install -g jugglingdb –save sudo npm install -g jugglingdb-mysql 复合inittesting应用程序 – db mysql 光盘testapp npm安装 $ node server.js 警告:JugglingDB适配器“mysql”没有安装, 所以你的模型将无法正常运行: npm安装jugglingdb-mysql /srv/www/playground/node/testapp/node_modules/jugglingdb/lib/railway.js:55 如果(!schema.adapter)抛出新的错误('适配器未定义'); ^ 错误:适配器未定义 在init(/srv/www/playground/node/testapp/node_modules/jugglingdb/lib/railway.js:55:36) 在CompoundServer.initialize(/srv/www/playground/node/testapp/node_modules/jugglingdb/index.js:31:19) 在CompoundServer.EventEmitter.emit(events.js:98:17) 在CompoundServer.initCompound(/srv/www/playground/node/testapp/node_modules/compound/lib/compound.js:123:14) 在CompoundServer.initCompoundServer [as init](/srv/www/playground/node/testapp/node_modules/compound/lib/server/compound.js:53:29) 在/srv/www/playground/node/testapp/node_modules/compound/lib/compound.js:67:18 在process._tickCallback(node.js:415:13) 在Function.Module.runMain(module.js:499:11) 在启动(node.js:119:16) 在node.js:901:3 […]