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

Get current values inside Sails' Waterline beforeUpdate hook

In Sails' Waternline I need to be able to compare the previous value with the new one and assign a new attribute under some condition. For example: beforeUpdate: function(newValues, callback) { if(/* currentValues */.age > newValues.age) { …
Talysson
  • 1,363
  • 1
  • 9
  • 13
5
votes
1 answer

Waterline: Populate model related object on create (Sails)

Token.create({ type: 'invite-into-org', email: email, initiator: organization, sender: req.user, metadata: { firstName: req.body.firstName, lastName: req.body.lastName, role: req.body.role …
vromanch
  • 939
  • 10
  • 22
5
votes
1 answer

SailsJS Waterline with Bluebird Promises

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) { …
Gayan Hewa
  • 2,277
  • 4
  • 22
  • 41
5
votes
1 answer

sailsjs "Error: There was an error turning the model into an object."

sailsjs 0.11, node 0.12.4. with passport 0.2.1 and passport-local 1.0 Using the sailsjs blueprint routes just to see what's going on. The project is just a simple blog, and I tried looking at a user profile in the blueprint route /user/4 to show me…
monsto
  • 1,178
  • 1
  • 13
  • 26
5
votes
1 answer

Sails.js Redis How to stream data?

I have been looking for info to know how to connect Redis to Sails.js throw model - controller - view and I think I've got it. My problem is that I think I don't understand the philosophy of Redis, its keys, etc. I guess my Redis has not any keys, I…
Victor Garcia
  • 59
  • 1
  • 2
5
votes
1 answer

sails.js extra fields on many to many relationships join table

I have two models: Order.js module.exports = { attributes: { //Id is generated by mongo and is a primary key address: { type: 'string', required: true, size: 1000 }, status: { …
Alexander Arutinyants
  • 1,619
  • 2
  • 23
  • 49
5
votes
1 answer

How do I store binary data from post to MongoDB

I have small images I want to store as a bin data item. The form is posted but I do not know what to do in the controller so that if I so this, the data is stored. I am using Sails.js and the form is passing data as "image" with the form having a…
latitudehopper
  • 735
  • 2
  • 7
  • 23
5
votes
2 answers

Before actions in Sails controller

Is there a way to have an action/function executed before each and all actions defined in a Sails controller? Similar to the beforeCreate hooks in the models. For example in my DataController, I have the following actions: module.exports = { …
tuvokki
  • 720
  • 1
  • 10
  • 18
5
votes
1 answer

Integrate DynamoDb in Sails js

Actually I tried to start a project with Sailsjs as DynamoDB data base. Searching the internet I found this package https://github.com/dohzoh/sails-dynamodb, I found that they have complete documentation for initial setup. I installed this package…
5
votes
1 answer

through associations in sails.js

A while ago I asked how to perform the "Through Associations". I have the following tables : genres +-----------+--------------+------+-----+ | Field | Type | Null | Key | +-----------+--------------+------+-----+ | id | int(6) …
johnmalkovitch
  • 375
  • 1
  • 3
  • 9
5
votes
1 answer

Aggregate nested model data in Sails.JS/Waterline

I'm struggling with where to put my business logic in my SailsJS project. My data model is as follows: Portfolio (hasMany) -> Positions (hasOne) -> Asset-> (hasMany) Ticks I'm looking to aggregate data of the children using computed properties on…
aphex2000
  • 51
  • 1
5
votes
2 answers

sometime sails js session does not destroy

I have create a web application using sails js. Following is logout function. logout: function(req, res) { req.session.destroy(function(err) { res.redirect('/'); }); } Sometime user does not logout from one click. But anyway…
Gayan Charith
  • 7,301
  • 2
  • 20
  • 32
5
votes
2 answers

How to access request object in sails.js lifecycle callbacks?

Suppose I have this model: module.exports = { attributes: { title: { type: 'string', required: true }, content: { type: 'string', required: true }, createdBy: { type: 'string', required:…
Martin Schaer
  • 3,986
  • 1
  • 23
  • 28
5
votes
1 answer

Get model identity from model instance

Is it possible to get a model's name/identity from an instance of that model? I would like to be able to pass a model to a service and have that service perform an action on that model based on what type of model it is.
Arlen Anderson
  • 2,486
  • 2
  • 25
  • 36
5
votes
1 answer

does Sails js populate association automatically?

Here two model with one to many relationship. Video: module.exports = { attributes: { ... (some attributes) createdBy:{ model: "user" } } }; User module.exports = { attributes: { ... (some attributes) videos:{ …
REALFREE
  • 4,378
  • 7
  • 40
  • 73