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

Waterline, error when trying to create one-to-many association

I have these models: // Material.js module.exports = { attributes: { name: { type: 'string', required: true }, source_info: { type: 'string', required: true }, category: { model: 'category_mat'…
arielmcm
  • 115
  • 1
  • 9
6
votes
1 answer

Sails.js Waterline query populate

Given that a user can have many accounts and an account can have many users, with an account always having an owner. Is there a better way to write this in Waterline query syntax? User.findOneByEmailAddress('user@acme.com').then(function(user) { …
Patrick Wolf
  • 1,329
  • 11
  • 28
6
votes
2 answers

Database schema with sails.js and sails-postgresql

Is there any way to set database schema with sails-postgresql waterline adapter? By default postgres adapter allways choose default public schema in database but I want to connect it to another schema. For example I have database dev, schema test in…
rafwlodar
  • 73
  • 1
  • 8
6
votes
3 answers

Waterline, find array in array

I have Video model: module.exports = { attributes: { id: 'string', tags: 'array' }, } I want to find all videos with tags for example "Hello" or "World". I could easy get all videos like: Video.find({tags:"Hello"}). I saw examples…
vromanch
  • 939
  • 10
  • 22
6
votes
1 answer

sails.js + waterline One-To-Many model association, what should happen when deleting the Many?

I have a one to many relation between Teacher(One) and Children(Many). If I do: Teacher.destroy(teacherId).exec(function(err){}); The children are not automatically removed. Is it a bug or should I delete them manually? If that's not a bug, what is…
user2867106
  • 1,139
  • 1
  • 13
  • 31
6
votes
6 answers

How do I handle a Unique Field in sails?

I've defined a unique field in my model but when I tried to test it seems like it's not being checked by sails because I get a Error (E_UNKNOWN) :: Encountered an unexpected error: MongoError: E11000 duplicate key error index: instead a sails…
ginad
  • 1,863
  • 2
  • 27
  • 42
6
votes
1 answer

sails.js - how can I acess session data in Model hook beforeCreate

I want to update a field 'owner' of a Model. The owner needs to be fetched from the session which contains the user who is currently logged in and is creating the Model. I want something like this: Model = { attributes: { }, …
Rahat Khanna
  • 4,570
  • 5
  • 20
  • 31
6
votes
3 answers

How to deal with promises in loop?

This is what I would like to do var response = []; Model.find().then(function(results){ for(r in results){ MyService.getAnotherModel(results[r]).then(function(magic){ response.push(magic); }); } }); //when…
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
6
votes
1 answer

Full text search with Sails.js

Is full text search possible with Sails.js and/or Waterline? I know PostgreSQL supports full text search, but it doesn't look like the PostgreSQL adaptor for Waterline supports that feature as far as I can tell. Would an efficient full text search…
5
votes
2 answers

Sailsjs. Best way to create (and manage) indexes on sails-mongo (mongodb)

I was using sailsjs 0.12. It supported index attributes on models, also i was using npm package Sails-hooks-mongoat to create inverse indexes and so. It wasn't ideal, but it worked. Right now they dropped the index attribute and mongoat is…
Gustavo Garcia
  • 1,905
  • 1
  • 15
  • 27
5
votes
1 answer

sails-postgresql AdapterError: Unexpected error from database adapter: there is no parameter $1

Im pretty new to sails, im trying to create an authentication schema in my postgresql db. I have an user model module.exports = { attributes: { firstName: { type: 'string' }, lastName: { type: 'string' }, email: { …
Matúš Bartko
  • 2,425
  • 2
  • 30
  • 42
5
votes
1 answer

sails.js - Getting blank page

It is properly working in my localhost. Issue only in another server. When I run this application from another server, getting a blank page like below, But api's are working properly. Landing page and no other pages are getting. This issue has been…
5
votes
1 answer

High frequency calls leads to duplicates with findOrCreate in Waterline & Sails

How to handle high frequency updateOrCreate requests with Waterline in Sails for a Postgresql database ? I tried to use findOrCreate and then update the item, I tried findOne and then update or create the item, I tried to put a beforeCreate, a…
SuperSkunk
  • 1,268
  • 12
  • 24
5
votes
3 answers

Google Cloud SQL No Response

We are running a Sails.js API on Google Container Engine with a Cloud SQL database and recently we've been finding some of our endpoints have been stalling, never sending a response. I had a health check monitoring /v1/status and it registered 100%…
5
votes
1 answer

Sails JS - Waterline ORM - Query Date only, not Time

Looking to query against the date only anyone encountered this? Sample code: ////MODEL module.exports = { attributes: { date: { type: 'date', required: true } } }; …
pim
  • 12,019
  • 6
  • 66
  • 69