Tag: 水线

Sails.js如何将数据插入连接表(多对多)

我有一个错误插入到我的连接表中的数据,我不知道我是否正确的做法。 这是我的两个模型,有多对多的关联。 Commit.js: module.exports = { schema: true, attributes: { idCommit : { type: 'integer', autoIncrement: true, primaryKey: true, unique: true }, revision : { type: 'integer', required: true }, issues: { collection: 'issue', via: 'commits', dominant: true } } }; Issue.js: module.exports = { schema: true, attributes: { idIssue : { type: 'integer', autoIncrement: […]

Node.js水线ORM – 生命周期callback – 在less数情况下,调用失败

我在我的应用程序中使用类似于这个模型,并且要求是在创buildlogging后,我想用新创build的loggingID更新所有者 。 所以我使用afterCreate方法来做同样的事情,但奇怪的行为是afterCreate方法不会在罕见的情况下被调用。 在手动创buildlogging时,我也有相同的行为,也是在摩卡单位testing中。 注意:这只在极less数情况下发生 。 那么,有没有最好的做法,或者我做错了什么? 我也有这个解决scheme以及..我所做的是,而不是使用afterCreate我在做同样的控制器行动..但只是期待知道为什么这会失败? **sample.js** module.exports = { schema: true, attributes: { name: { type: 'string', required: true }, owner : { model: 'sample' } }, afterCreate : function(values, next) { sample.update({id:values.id}, {owner: values.id}) .exec(function(err, result){ if(err){ next(err); } next(); }); } };

toJSON()不能在一个充满json对象的数组上工作

更新的问题 我使用sails.js v0.10.5 而我试图使用帆到JSON()和即时尝试删除一些东西从服务器之前,它被发送到客户端。 所以我有一个用户查找系统,有人可以写一个名字,然后Typeaead将查询我的数据库使用Sails作为后端。 现在,build议以包含多个用户的数组作为对象发送。 返回的对象如下 [ { "_id": "55394747d01d6777e09f4919", "index": 0, "guid": "1e08f17d-0163-40f6-b673-c9b1823b3e9b", "isActive": true, "balance": "$2,994.39", "picture": "http://placehold.it/32×32", "age": 28, "eyeColor": "brown", "name": "Grant Hughes", "gender": "male", "company": "CUBIX", "email": "granthughes@cubix.com", "phone": "+1 (972) 415-2367", "address": "656 Hornell Loop, Farmers, New York, 7735", "about": "Elit aute veniam commodo do dolore labore ullamco […]

如何在模型的属性方法中正确使用水线承诺?

在Model我使用的属性方法将查找数据库,不得不查询其他不同的模型。 所以我使用水线承诺,但我不知道如何实际执行模型的属性方法本身的返回方法,这就是我正在做的: 我们称之为LineUp模型: module.exports = { connection: 'seasonDB', attributes: { reachesMaxFavoriteTeam: function (team) { UserTeam.findOne(). where({id: this.userTeam}). then(function (team) { User.findOne(). where({id: team.userId}). then(function (user) { return [team, user.fanOf]; // I assume to be returning for the spread function }). spread(function (team, user) { // How can I make reachesMaxFavoriteTeam return something here??? }).catch(function (err) […]

如何在sails中使用MongoDB而不是waterline

我有一个大约有600000条logging的数据库。 我正在使用sails.js,但是当我用水线方式获取数据需要很长的时间来获取600000条logging(约17秒),并有限的查询,即它没有访问连接表。 所以我join了两个查询的结果,然后过滤掉这个数据就花了很多的时间。 所以我决定使用MongoDB来代替水线,而我想知道是否可以在不连接到Waterline模型的情况下使用Blueprint API。 如何使用MongoDB而不是水线?

使用sails.js和postgreSQL时出错(使用sails-postgresql模块)

我想问个问题。 我正在开发一个应用程序使用sails.js和PostgreSQL(使用sails-postgresql模块)。 我使用的是我的主键types而不是整数的UUID。 但是当我尝试向我的数据库插入数据时有一些错误。 我的模型UserModel.js var uuid = require('node-uuid'); module.exports = { adapter: 'somePostgresqlServer', autoPK: false, migrate: 'safe', attributes: { ID: { primaryKey: true, type: 'string', defaultsTo: function (){ return uuid.v4(); }, unique: true, index: true, uuidv4: true }, username: { type: 'string', required: true, unique: true } } }; 我在控制器中创buildfunction create: function(req, res) { […]

水线:尝试访问未定义的收集string

我用Sails.js使用Waterline。 我想要一个拥有Involved的用户 。 一个事件可以有多个参与 。 一个参与有一个地位。 我的用户类: module.exports = { attributes: { involvements: { collection: 'Involvement', via : 'user' } } }; 我的活动class级: module.exports = { attributes: { creator: { model: 'User' }, involvements: { collection: 'Involvement', via: 'event' } } }; 我的参与课: module.exports = { attributes: { status: { type: 'string', required: true }, […]

如何在一个操作中保存SailsJS中的多个logging?

我想知道最好的做法是保存多个logging的操作,使更改,特别是添加和删除多个logging。 最终目标是让一个function可以访问操作中所有已更改的数据。 目前我正在嵌套保存,以便最内层的保存可以访问所有更新logging中的数据。 这里是我如何保存的一个例子: record1.save(function (error, firstRecord) { record2.save(function (erro, secondRecord) { record3.save(function (err, thirdRecord) { res.send({recordOne: firstRecord, recordTwo: secondRecord, recordThree: thirdRecord}); }); }); }); 通过这种保存结构,recordOne,recordTwo和recordThree在服务器上显示期望值。 但是,检查localhost / 1337 / modelName显示模型没有正确更新,并有不正确的数据。

将现有的SQL Server导入SailsJS和Waterline?

我有一个300-400表的大型SQL Server数据库,我想做一个POC来尝试SailsJS。 有没有什么可以将现有的SQL Server数据库导入Waterline模型?

sails.js服务中的水线错误实现

由于大多数人知道sails.js框架作为WLError对象抛出错误,所以我希望在我的应用程序中使这一点保持一致。 任何我想在我的服务中提出的错误应该是一个WLError对象与我自己的错误,状态和总结。 有没有人做过这个? var error = new Error(errorMsg); return error; 我想要下面的东西… var error = new WLError({"status":"Fail", "error": "somethig", "summary": "OOPS!!"}); return error; 谢谢!