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
8
votes
1 answer

Update multiple records at once using SailsJS

So I'm making this app where I will have menu items for a restaurant right ? The owner should have the ability to move around the menu items This is my menuitem.js Model contains name , price , position That's it. Super simple. So to reposition…
Andre Frexio
  • 155
  • 1
  • 10
8
votes
3 answers

Specify returned fields in Node.js / Waterline?

I want to make a request like: User.find().exec(function(){}); I know I can use toJSON in the model however I don't like this approach since sometimes I need different parameters. For instance if it's the logged in user I will return their email…
Rob
  • 10,851
  • 21
  • 69
  • 109
8
votes
1 answer

How to set database connection string in Waterline ORM

I just downloaded Waterline from npm. I got some folders, but cant find where can i set the host/user/password etc. to connect my postgress database. I watched all files in the waterline folder and nothing. Can anyone tell me where set it ?
CSharpBeginner
  • 1,625
  • 5
  • 22
  • 36
8
votes
1 answer

Inherit attributes and lifecycle functions of Sails.js models

I want to create a custom set of attributes and lifecycle methods that are shared between all my Sails.js models. Sails.js automatically creates and registers the model objects by calling the Waterline.Collection.extend() method and providing the…
david.schreiber
  • 3,851
  • 2
  • 28
  • 46
8
votes
2 answers

Sails.JS - Get the count of the number of objects/rows in the database

In Sails.js, a lot of work is done for you by generating the models and controllers. The controllers allow for access to the data through API's. It allows for easy pagination by passing the start/skip/offset and take/limit. But in order for me to…
TheSharpieOne
  • 25,646
  • 9
  • 66
  • 78
8
votes
3 answers

How can I call a model instance method in lifecycle callback in Sails/Waterline?

I have set up a simple model with 2 instance methods. How can I call those methods in lifecycle callbacks? module.exports = { attributes: { name: { type: 'string', required: true } // Instance methods doSomething:…
ragulka
  • 4,312
  • 7
  • 48
  • 73
8
votes
2 answers

Push values into array of mongodb database through (sails js) waterline

node js,sails js,waterline. I need to update(or push) values into the below schema after insert I am using sailsjs with waterline and mongodb. { "countries": { "states": [ { "statename": "state", "districts": [ { "distname": "district", "cities":…
Shiva Gouraram
  • 147
  • 1
  • 7
7
votes
1 answer

How to test waterline models in Trails.js

I wanted to test the models of my Trails.js project with mocha. I use the trailpack-waterline to load my models into the Waterline ORM. Following the Trails Docs I created a User.test.js: 'use strict' const assert =…
Lando-L
  • 843
  • 6
  • 19
7
votes
3 answers

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

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…
ygrunin
  • 325
  • 1
  • 4
  • 15
7
votes
1 answer

How to know which attribute called the waterline validation rule?

I'm doing my own custom validations on certain fields, so that only certain values are accepted (depending on the field) and the rest rejected. I would like to write a "filter" function that checks what attribute called the validation and from there…
JamHam
  • 105
  • 4
7
votes
2 answers

sails.js: Lifecycle callbacks for Models: Do they support beforeFind and afterFind?

In sails.js, Models support lifecycle callbacks for validate, create, update and destroy. Is there support for callbacks for find() or query as well? Like beforeFind() and afterFind()? The idea is same. I would want to validate / modify parameters…
rsmoorthy
  • 2,284
  • 1
  • 24
  • 27
7
votes
2 answers

Model validation fails in Sails.js

I tested the following Employee.js model in Sails.js and I found something that seems hard for me to understand. When the form for creating a new Employee is posted, I got the following errors with the 1st definition of Employee.js model, but the…
TonyW
  • 18,375
  • 42
  • 110
  • 183
7
votes
1 answer

Waterline associations, change foreign key?

The latest waterline now supports associations. Here is an example of a one-to-many // A user may have many pets var User = Waterline.Collection.extend({ identity: 'user', connection: 'local-postgresql', attributes: { firstName:…
InternalFX
  • 1,475
  • 12
  • 14
7
votes
4 answers

Sails js and Sequelize

I'm learning Node.js and Sails is my framework of choice. I want to use it in a project with MySql db and I think that Sequelize Orm is more complete. How can I use Sequelize Orm in Sails instead of Waterline? Thanks
Mino
  • 635
  • 10
  • 28
7
votes
2 answers

Sailsjs Geospatial Solution with Waterline

It seems like Sailsjs/Waterline does not currently support a POINT type or geospatial indexing with JSON. Are there any ways to customize a schema for certain adapters to support geospatial datatypes? If not, is there a way to integrate a second…
gtg092x
  • 171
  • 2