Questions tagged [waterline]

Waterline is an adapter-based ORM for Node. It is included with the Sails.js framework.

Waterline provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. That means you write the same code to get users, whether they live in MySQL, LDAP, MongoDB, or Facebook.

At the same time, Waterline aims to learn lessons and maintain the best features from both Rails' ActiveRecord and Grails' Hibernate ORMs.

Waterline uses the concept of an Adapter to translate a predefined set of methods into a query that can be understood by your data store. Adapters allow you to use various datastores such as MySQL, PostgreSQL, MongoDB, Redis, etc. and have a clear API for working with your model data.

It also allows an adapter to define it's own methods that don't necessarily fit into the CRUD methods defined by default in Waterline. If an adapter defines a custom method, Waterline will simply pass the function arguments down to the adapter.

Project GitHub


Related tags :

1230 questions
11
votes
1 answer

How to define instance methods for models with sails.js

How can I define functions/instance method for objects in Sails ? In Waterline doc (https://github.com/balderdashy/waterline) they say: var User = Waterline.Collection.extend({ ... attributes: { ... // You can also define instance methods…
Adrien
  • 715
  • 6
  • 14
10
votes
1 answer

How to create a new instance of waterline model without saving it

This might be a very simple question but I don't find anything about it in the Waterline docs. How is it possible to get an instance of a Waterline model without immediately saving it. Model.create(data); // already written to database I am looking…
Ole Spaarmann
  • 15,845
  • 27
  • 98
  • 160
10
votes
2 answers

How can I add an instance method to all Models in sails.js?

I'd like to add a default toDisplay function to all models which will use metadata, not unlike attribute/association definitions, to perform manipulations on the instance's attributes/associations making them suitable for display in the UI. for…
umassthrower
  • 1,307
  • 1
  • 11
  • 15
10
votes
1 answer

sails postgresql many-to-many association not working

I'm trying to create a many to many association between two models, Operator and Group. Two two models are: -Operator.js var Operator = { connection:'postgresql', tableName: 'operator', schema:true, attributes: { firstName:…
10
votes
2 answers

Drop the entire sails-memory database?

I'm using 'sails-memory' as the database for my Sails unit tests and ideally would like to clear the entire database after individual tests. Is there a way I can drop the entire database?
HolySamosa
  • 9,011
  • 14
  • 69
  • 102
10
votes
2 answers

how to set default value for a field in Sails models using Waterline ORM?

A very simple question but I am unable to find the answer to it. So in my Sails app I have a User model and I am trying to make a boolean field with a default value to be False. Is there a way to specify defaults like some kind of default attribute…
Gagandeep Singh
  • 316
  • 1
  • 4
  • 8
10
votes
2 answers

Sails.js Waterline query modifiers for dates with sails-mysql?

I just started using Sails.js with its ORM, Waterline, and absolutely love it, but I am not sure how to use query modifiers for dates. I am using sails-mysql. Specifically, I am trying to get rows that have a datetime field between two specific…
lmanco
  • 131
  • 1
  • 7
10
votes
2 answers

Is it possible in Sailsjs to build more complex models

I would like to have arrays or collections in my model, is this yet possible with waterline (mongoDB)? are there any alternatives around? example: { name: Bundle, col1 : { name : anOtherModel, subCol: { text: aString, …
Omid Hashemi
  • 207
  • 2
  • 13
9
votes
2 answers

Hidden properties to console.log or utils.inspect

I'm working with sails.js waterline orm. Now this is not particularly a sails question, but i have to place some context, so when you create a record you get back an object with the data created. If the record has other records (collections)…
Lu Roman
  • 2,220
  • 3
  • 25
  • 40
9
votes
1 answer

Best way to migrate table changes to production sailsjs tables

I just lost 11,000 records from my database just running the command for sailsjs without the --prod part in it, So I thought I should ask whats the best way to change the tables on production server when the Model.js has been changed ? Thanks
Sahan
  • 1,422
  • 2
  • 18
  • 33
9
votes
4 answers

Sails.js Same Model many to many association

Sails.js .10 rc8 I've completely run out of ideas for this I have a model called User and I want to associate it in a collection to other users like a friends list. Like a many-to-many association //User.js friends: { collection: 'user', …
scott
  • 583
  • 6
  • 11
9
votes
4 answers

Sails js - waterline ORM limit or sort after group by?

I am using Waterline ORM for sails.js. limit and sort are not working when you use groupby, but are working fine when you dont do any grouping . For example Model.find({ groupBy:['term'], sum:['count'], limit:20, sort :'count…
sanath_p
  • 2,198
  • 2
  • 26
  • 22
9
votes
1 answer

Sails JS Waterline join of multiple models

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…
Sandro Adamia
  • 463
  • 1
  • 5
  • 13
9
votes
1 answer

How to perform a "$in" query with Waterline and MongoDB

I am trying to do a "$in" query with waterline I have an Array and I want to get a list of document with ids that are in the array. I don't know how to do that. I tried: User.find() .where({id : {in : array}}) done(...) But it doesn't seem to work…
adc06
  • 793
  • 8
  • 23
8
votes
4 answers

Find and count all in Sails.js + Waterline

Is there a way to do select query and count_all query via single method? For pagination purposes we need to know total number of items so we can calculate and show number of pages.
Kristian Ačkar
  • 895
  • 1
  • 9
  • 13
1 2
3
81 82