waterline

How to selectively populate waterline associations via query param in sails.js

耗尽温柔 提交于 2019-11-29 06:22:18
问题 By default, sails will populate all relationships within a model when it's corresponding API route is hit. Does anyone know if it's possible to toggle this functionality? If I'm working with a one-to-many association, I may not want to populate the association when doing a listing of all items for performance reasons. But when viewing a single item, it would be nice to complete the population. For example, say one ticket can have many comments. I don't care about the comments when fetching a

Using Waterline model outside SailsJS api

谁都会走 提交于 2019-11-29 03:42:25
Is it possible to use models defined within [app-name]/api/models outside api folder? I have created separate folder in application root, where I placed cron job that should fill my database every hour. I would like to reuse Models defined inside my api folder, but not sure how to do it. I see that I can do sails.lift inside that cron script but that doesn't seem very nice to me. Did someone experience something similar? I'm new to node.js, so maybe I'm missing something pretty obvious. If your concern with using sails.lift is that it starts an actual HTTP server that listens for requests, you

How to perform SQL Joins and Relations in Sails.js and Waterline?

时光毁灭记忆、已成空白 提交于 2019-11-29 02:11:06
问题 Can anyone guide me on how to setup relational schema & performs joins in sails.js? 回答1: Associations are officially Supported in Waterline Overview From the docs: With Sails and Waterline, you can associate models across multiple data stores. This means that even if your users live in PostgreSQL and their photos live in MongoDB, you can interact with the data as if they lived together in the same database. You can also have associations that span different connections (i.e. datastores

How to use Sequelize in SailsJs

戏子无情 提交于 2019-11-28 19:20:05
问题 Waterline is an excellent ORM but I noticed that there are many features that are not present yet on waterline but Sequelize already have. So I have decided to switch to sequelize but still using Sails for the others things. I have search tutorial how to switch to sequelize but nothing. How can I replace Waterline for sequelize in sails Js? 回答1: I've moved forward with sequelize as well, there are two project that came out really recently, so i would like to announce them. sails-hook

How to properly do a Bulk upsert/update in MongoDB

陌路散爱 提交于 2019-11-28 13:30:27
I'm trying to: Find a document according to a search criteria, If found, update some attributes If not insert a document with some attributes. I'm using a Bulk.unOrderedOperation as I'm also performing a single insert. And I want to do everything in one operation againast DB. However something it's causing nothing is being inserted for the update/upsert operation. This is the insert document: var lineUpPointsRoundRecord = { lineupId: lineup.id, // String totalPoints: roundPoints, // Number teamId: lineup.team, // String teamName: home.team.name, // String userId: home.iduser, // String

Sails.js populate with where

断了今生、忘了曾经 提交于 2019-11-28 08:41:59
问题 I need to select users with dogs (pets with type equal 'dog') var User = Waterline.Collection.extend({ identity: 'user', attributes: { firstName: 'string', lastName: 'string', pets: { collection: 'pet', via: 'owner' } } }); var Pet = Waterline.Collection.extend({ identity: 'pet', attributes: { type: 'string', name: 'string', owner: { model: 'user' } } }); I didn't find any examples, I tried like this User.find().populate('pets', {type: 'dog'}).exec(err, users) ... and this User.find().where({

Is there a way to disable waterline and use a different ORM in sails.js?

試著忘記壹切 提交于 2019-11-28 08:19:27
I'd like to replace waterline with mongoose in my sails.js application. I'm looking for the correct way to do this, but I don't see how in the documentation. Can anyone explain how to do this? Defining overrides via .sailsrc You could do this via config overrides, to be defined via .sailsrc in your project root. Basically you have to prevent the entire Waterline initialization, currently tagged as orm hook. In .sailsrc: { "hooks": { "orm": false, "pubsub": false } } You'll have to disable the pubsub hook as well - it depends on the orm hook. Relevant lines in the source: v0.10 , v0.9.8 . This

npm install not installing things at /usr/bin

时间秒杀一切 提交于 2019-11-28 01:44:48
问题 I am trying to install SailsJS with: $ sudo npm install -g sails It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails with the following log: /home/brunoluiz/npm/bin/sails -> /home/brunoluiz/npm/lib/node_modules/sails/bin/sails.js sails@0.9.16 /home/brunoluiz/npm/lib/node_modules/sails ├── connect-flash@0.1.1 ├── pluralize@0.0.5 ├── inflection@1.2.5 ├── grunt-sails-linker@0.9.5 ├── grunt-contrib-clean@0.4.1 ├── node-uuid@1.4.0 ├── async@0.2.9 ├── grunt-contrib-concat@0.3

Using Waterline model outside SailsJS api

倖福魔咒の 提交于 2019-11-27 17:43:50
问题 Is it possible to use models defined within [app-name]/api/models outside api folder? I have created separate folder in application root, where I placed cron job that should fill my database every hour. I would like to reuse Models defined inside my api folder, but not sure how to do it. I see that I can do sails.lift inside that cron script but that doesn't seem very nice to me. Did someone experience something similar? I'm new to node.js, so maybe I'm missing something pretty obvious. 回答1:

Sails JS Waterline join of multiple models

半城伤御伤魂 提交于 2019-11-27 07:47:03
问题 Hi i'm trying to join multiple tables with populate method, i googled and couldn't find efficient way of doing it, i do not want to query db several times to build the result, is it possible to solve it with sails version "~0.10.0-rc7" i'm building quit big project with more then hundred of tables. var co = { adapter: 'someMysqlServer', migrate:'safe', autoCreatedAt: false, autoUpdatedAt: false, autoPK:false, attributes:{ id:{ type:"int", primaryKey: true, autoIncrement: true }, code:"string"