waterline

sails.js waterline nested populate query

让人想犯罪 __ 提交于 2019-12-23 16:05:35
问题 I have a find query that returns multiple results of an object, this object contains a model that contains another model, the thing is that waterline doesn't support nested populates, so it populates the first model but not it's inner model. all the examples I've seen for that are for a findOne query, i am looking for a way to resolve that for a find query that returns multiple results. This is my models structure: // Container.js widgets: { model: 'websitewidget' } // WebsiteWidget.js html:

SailsJS Waterline with Bluebird Promises

无人久伴 提交于 2019-12-23 09:57:59
问题 When using the waterline ORM, if I want to consume the bluebird promise api thats shipped by default how to I pass the processing back to the controller. Below is the code : module.exports = { //Authenticate auth: function (req, res) { user = req.allParams(); //Authenticate User.authenticate(user, function (response) { console.log(response); if (response == true) { res.send('Authenticated'); } else { res.send('Failed'); } }); } }; module.exports = { // Attributes // Authenticate a user

“email” validation rule crash sails server - Mongo with Sails.js

妖精的绣舞 提交于 2019-12-23 08:07:21
问题 while the email validation rule fails on module of the sails.js, the server is crashing. Here the snippet of my module: // The user's email address email: { type: 'string', email: true, required: true, unique: true }, And the error as below : err: Error (E_VALIDATION) :: 1 attribute is invalid at WLValidationError.WLError (C:\Users\yuri\AppData\Roaming\npm\node_modules\sails\node_modules\waterline\lib\waterline\error\WLError.js:26:15) at new WLValidationError (C:\Users\yuri\AppData\Roaming

Using between query for full date format in Sails.JS Waterline

徘徊边缘 提交于 2019-12-23 05:22:20
问题 According to Between Dates using Waterline ORM SailsJS it is possible to do a between query on dates in the Waterline adapter like the following: User.find({ createdAt: { '>': dateFrom, '<': dateTo } }).exec(/* ... */); However, this does only work with date formats like 2018-04-11 . Is it somehow possible to use the full ISO8601 date format in this query: e.g. 2018-04-11T12:45:00.000Z ? EDIT: Added minimal working example code. readDataInDateRange: function(req, res) { var dateFrom = req

How to upload a file using the new controller actions format in sails.js

别来无恙 提交于 2019-12-23 05:12:29
问题 Someone know how I could upload a file to a controller action using the (inputs, exists) format of sails.js, this is my try: module.exports = { friendlyName: 'Upload file recording', description: 'Upload a recording to AWS', inputs: { name: { required: true, type: 'string' }, mimeType: { required: true, type: 'string' }, recording: { type: 'ref' } }, exits: { noRecordings: { responseType: 'no recordings', description: `You don't have any recording for this event`, }, serverError: {

the best way to exclude some data from a method in sails controller

試著忘記壹切 提交于 2019-12-23 02:01:58
问题 I want's to exclude some data in some controller method and in other method i want's that data. I do it with forEach function right into method after finding that : nine: function (req, res) { Dore.find() .limit(9) .sort('createdAt DESC') .populate('file') .exec(function (err, sh) { if (err) { return res.negotiate(err); } else { console.log('before : ', sh); sh.forEach(function (item, i) { delete item.zaman; }); console.log('after : ', sh); return res.send(sh); } }); }, I want to know how

Service that returns data from an asynchronous method

喜夏-厌秋 提交于 2019-12-22 18:36:16
问题 I am using Sails' ORM (Waterline). I have written a geturl service that should return the url of several models/actions in my app. I am currently calling this service inside my templates. (As I am alone to develop this, don't hesitate to warn me if this design pattern is wrong) Now it occurs that Waterline's .find() method is asynchronous (as it should). I always use callbacks to do things when inserting or fetching things in database. Now I have seen everywhere that I cannot return any data

String of certain length in Sailsjs Model

放肆的年华 提交于 2019-12-22 14:55:17
问题 How can I enforce a Model property to be exactly 32 characters long? I have tried key : { type: 'string', len : 32 } but it doesn't work. 回答1: Ok, let me tell you what i did. After reading hours y figure out that "columnType" property is the solution. It works together with "type" property. For example. I have a "description" field. It looks like: descripcion: { type: 'string', columnType: 'varchar (27)' } And it works. (this is for mysql db). I hope this works for you. This is on the docs.

SELECT and UPDATE multiple records in oriento / orientjs and transaction in waterline

做~自己de王妃 提交于 2019-12-22 01:49:25
问题 How can I select or update multiple records in oriento? Like in waterline we can offersModel.update({id:items_ids,status:INACTIVE},{status:ACTIVE}) But in waterline transaction is not available. So I want to use : var db = offersModel.getDB(); var trans = db.begin(); trans.update('offers') .set({status:INACTIVE}) .where({id:items_ids,status:ENM.SELLING_STATUS.ACTIVE})//.exec() .then(function(offers){ if (offers.length != items_ids.length) {trans.rollback(); /* send error here*/} else trans

Sailsjs/waterline specify number of decimal places in model

假装没事ソ 提交于 2019-12-21 19:54:49
问题 How do I tell my sails model that I want some specific number decimal places for a type: 'float' attribute? Like decimalPlaces: 4 or something of that ilk? The problem is that when i post a value to this entry, the value on disk is truncated to the .00 (hundreds) place. Say I want: 3243.2352362 to be stored just as it is. Currently this is transformed into 3243.24 If it matters I'm using the sails-mysql adapter. 回答1: types: { decimal2: function(number){ return ((number *100)%1 === 0); } },