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
3 answers

How to make transactions with sails.js/waterline?

I am trying to put my queries into transaction and I am failing in runtime. Error I am getting is : Object # has no method 'transaction' I tried to follow this "documentation". In short my model looks like that : updateOrCreate: function…
wonglik
  • 1,043
  • 4
  • 18
  • 36
5
votes
2 answers

sailsjs / waterline query "where" not empty

Hy there, Before going to the hacky / cutom way i wanted to know if there is a built in query way to check for an empty / non empty many to many relationship as i was not successfull neither on google nor the doc. If i take the example in the doc…
MrVinz
  • 874
  • 6
  • 15
5
votes
2 answers

Soft delete in Sails/Waterline

Trying to delete a user model using: //Hard Delete User.destroy({id:userId}, function(err, res){ //Hard Delete }) I need to do a soft delete on User model and currently setting a flag isDeleted to true on delete and updating…
Abhishek
  • 1,999
  • 5
  • 26
  • 52
5
votes
1 answer

How to add json object as a type for attributes in sails-mongo

Document.js module.exports = { attributes: { type: { type: 'string' }, createdBy: { model: 'User', required: true }, body: { type: 'string' }, comments: { model: 'Comments' …
DivyaMenon
  • 311
  • 4
  • 19
5
votes
2 answers

How to create 'calculated' fields at Waterline/Sails.js Model?

This is my Users.model: module.exports = { attributes: { name: { type: 'string', required: true, minLength: 3, maxLength: 30 }, username: { type: 'string', …
Marcelo Boeira
  • 860
  • 8
  • 22
5
votes
3 answers

SailsJS and Mongo unique attribute is ignored

I cant seem to get the unique attribute to actually check/validate for unique values while using Mongo in SailsJS. I end up with identical usernames easily. Any thoughts? I checked the other post about this, but that was related to using…
5
votes
3 answers

Sails.js & Waterline ORM unset key MongoDB

What method is used to unset a key in MongoDB with Waterline ORM? Consider the following document: { name : 'brian', age : 29 } Getting the user is no problem: var users = Users.findOne({ name : 'brian' }).exec(cb); I would like age to…
brian
  • 2,745
  • 2
  • 17
  • 33
5
votes
1 answer

How to use the "find where" SailsJS blueprint route?

Use Case I'd like to create a complex query with more than one criterion using the SailsJS "Find Where" blueprint route. However, I am unable to use the equals comparator and the and condition successfully. I couldn't find adequate documentation on…
Pete
  • 3,246
  • 4
  • 24
  • 43
5
votes
1 answer

Sails.js calling one controller action from another and passing additional params in req.body

I need to call a controller action from another action. So far, I have not been required to pass any additional params and the call sails.controllers.modelName.actionName(req, res) does the job. However, this time I need to add new param to…
Mandeep Singh
  • 7,674
  • 19
  • 62
  • 104
5
votes
1 answer

How to update a hashed password with validation in Waterline?

The Waterline docs give an example of using beforeCreate to hash a password. That works great unless you have validation on the password field and you try to update the record. Here's my snipped example: types: { hasUpperCase: function (value)…
Andrew Eddie
  • 988
  • 6
  • 15
5
votes
1 answer

Sails Waterline SQL join in populate

Does Waterline have any support for performing SQL joins (aside from query())? I've set up the associations in my models, but the actual SQL queries that are generated are looping select statements. Is there currently only support for "n+1…
5
votes
1 answer

Module for Sailsjs

I am facing a new project that will be probably made with sails.js. Is there any way to write 'modules' for Sails, so I can isolate specific views, controllers, models, services, etc. in a module (folder) I can add or remove easily? If not, any idea…
Ignacio
  • 688
  • 5
  • 17
5
votes
1 answer

Waterline (Sails.js). Rows with 'updatedAt' greater than a given value

I want to get the new rows from a model. The rows that have been created after a given date. The query should be very easy: where updatedAt >= givenDate But it's not working :( My code: // Date from client var lastDate =…
josec89
  • 1,932
  • 1
  • 16
  • 19
5
votes
2 answers

sails.js nested models

In sails.js 0.10 I'm trying to do the following // user.js module.exports = { attributes: { uuid: { type: 'string', primaryKey: true, required: true } , profile: { firstname: 'string', …
Kaiusee
  • 1,253
  • 1
  • 14
  • 28
5
votes
1 answer

Can't create composite primary keys using waterline

It seems that waterline-mysql doesn't allow composite primary keys to be created. Is there any way of working around it, since I am building an app on the top of an existing database?
tebesfinwo
  • 715
  • 1
  • 6
  • 20