waterline

Waterline Transaction through sails-orientdb

帅比萌擦擦* 提交于 2019-12-11 10:57:31
问题 I'm using transaction in the following code, can I enhance this code furthermore? var db = itemsModel.getDB(); var trans = db.begin(); trans.update('items') .set({status:UNAVAILABLE}) .where({id:items_ids_list,status:AVAILABLE}).exec() .then(function(items){ if (items.length != items_ids_list.length) { trans.rollback(); /* send error here*/ } else trans.commit(); }); 来源: https://stackoverflow.com/questions/29586175/waterline-transaction-through-sails-orientdb

Use And in Waterline

微笑、不失礼 提交于 2019-12-11 10:17:11
问题 This is my query using waterline var queryObject = { where: { or: [ {firstName: {'contains': search}}, {lastName: {'contains': search}}, {email: {'contains': search}}, ], and: [ {authType:'google'}, {dealershipcompany: 11} ] } } yet adding 'and' return an error: error: Sending 500 ("Server Error") response: Error (E_UNKNOWN) :: Encountered an unexpected error : ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right

Sails.js many-to-many associations throw error on create and populate

这一生的挚爱 提交于 2019-12-11 09:17:04
问题 When I try to associate one collection with another collection using a many-to-many association, I get the following error: Using sails-mongo: TypeError: Cannot read property 'where' of undefined at _afterFetchingJunctorRecords (/Users/grant/Sites/sails/test/node_modules/sails-mongo/node_modules/waterline-cursor/cursor/populateBuffers.js:131:35) at /Users/grant/Sites/sails/test/node_modules/sails-mongo/lib/collection.js:103:5 at /Users/grant/Sites/sails/test/node_modules/sails-mongo/node

How do I update a specific key inside a MongoDB sub-document using Sails.js & Waterline?

邮差的信 提交于 2019-12-11 08:39:59
问题 I face an issue when trying to update a single key inside a MongoDB sub-document using Sails.js and the Waterline ORM. This is what my person.js model looks like: module.exports = { attributes: { name: { type: 'string', required: true }, favorites: { type: 'json', defaultsTo: { color: null, place: null, season: null } } } } Now, let's say I want to update a specific person's name and favorite season from my controller, I am doing this: Person.update({ id: '1' }, { name: 'Dan', favorites: {

When i use Waterline's create method, it doesn't return the new record's ID

为君一笑 提交于 2019-12-11 08:27:38
问题 When i create a new record using Waterline's create method, the created object is returned, but without it's ID. How can I get the id of the last inserted object? I'm using the mysql adapter on mariadb if it makes any difference 回答1: It seems like you're probably doing something wrong. I have not done any additional configuration to waterline, anyway it returns id every time when I use new query as well as record at all. In most cases I don't create id field in sails model, auto-generation

How to get the primary key attribute name of a model? (waterline ORM)

六眼飞鱼酱① 提交于 2019-12-11 08:15:58
问题 Some of my models do not have id as their primary key, and I need to know the name of the primary key of a given model but I couldn't find a way of doing this. I searched in the waterline docs and source, but all what I found in the their source is that they are using the attributes object definition which is stored in a unaccessible variable in the lib scope. The "cleaner" way I found to do it for now is like this: // file: api/libs/model.js module.exports = { //... primaryKeyName: function

Cannot update attributes in Sails.js model instance

只愿长相守 提交于 2019-12-11 07:56:51
问题 After updating to Sail.js 0.10.1, I've been getting an error while trying to update attribute fields of a specific instance of a model. I've tried doing User.find() as well, then setting user.attribute = someValue, and then calling user.save(), and this very same error occurred. Here is the relevant code: // TODO: Save user params (for edit/updates) save: function(req, res) { var params = req.params.all(), updateParams = {}; if (params['publicKey'] != '') { sails.log.debug('Updating public

Why wouldn't a waterline callback happen to be triggered?

一曲冷凌霜 提交于 2019-12-11 04:25:02
问题 I'm using Sails built in models and it's ORM to perform MongoDB queries and operations. The problem I got is that, for some query methods,it's callback is never being called. The DB operation gets done, but callback won't come up. Following code snippet is model querying part of a controller method for an API, that's why I'm using a response object. LineUp.update({ id: request.param('id') }, { players: [], budgetLeft: 60000000 }). exec(function (err, lineup) { console.log("Should happen");

BreezeJS on Durandal with PHP REST API (Laravel)

人盡茶涼 提交于 2019-12-11 04:05:27
问题 I'm writing a SPA in Durandal 2.1. So far so good. However, I'm having great difficulties in selecting the right Data Persistence library to communicate with my PHP (Laravel) REST API. The number one library for Durandal is BreezeJS. It is said that it supports API's without oData / ASP.NET Entity framework. I've searched for many days now, but I can't find any decent resource telling me how to use BreezeJS with my basic PHP REST API. The wish-list is as follows: Persist data between views

sailsjs array query Exact match

跟風遠走 提交于 2019-12-11 03:16:46
问题 i want to query mongodb in sailsjs. this is structure of my db { "users": [ "52ed09e1d015533c124015d5", "52ed4bc75ece1fb013fed7f5" ], "user_msgs": [ { "sender": "52ed09e1d015533c124015d5", "sendTo": "52ed4bc75ece1fb013fed7f5", "msg": "ss" } ], "createdAt": ISODate("2014-02-06T16:12:17.751Z"), "updatedAt": ISODate("2014-02-06T16:12:17.751Z"), "_id": ObjectID("52f3b461f46da23c111582f6") } I want to search those "users" who who match array [ "52ed09e1d015533c124015d5", "52ed4bc75ece1fb013fed7f5"