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

Why sails-orientdb tries to create a new database every time i start my app?

I am using sails-orientdb as an Waterline Adapter but there is a problem whenever I restart my application it tries to create a new database which was already created as I am using it for the first time so I don't know the structure and functions…
0
votes
2 answers

Sails-mongo many to many association not working

I am using sails 0.10.5 , and i have two models as below for many to many relation. but i am getting error while lifting app. model 1) Category.js attributes: { name: { type: 'string', required: true }, …
Nishchit
  • 18,284
  • 12
  • 54
  • 81
0
votes
1 answer

How to use Waterline for replace element in database and compare with text for find?

I use Sails and Waterline, and i would compare username in url with database elements for find an user. http://localhost:1337/johndoe (or id) find John Doe in database. My controller, for the moment : user: function (req, res) { var user =…
user4034421
0
votes
1 answer

One model attribute equal to the other by default in sail.js model

Is there a way to set one attribute equal to the other in sails.js model before it is not updated? Something like: username: { type: 'string', required: true }, fullname: { type: 'string', defaultsTo: this.username }, ...
Boris Zagoruiko
  • 12,705
  • 15
  • 47
  • 79
0
votes
1 answer

Sails model query

I have 3 models (Room, Module and Device) : Room : /** * Room.js * * @description :: TODO: You might write a short summary of how this model works and what it represents here. * @docs :: http://sailsjs.org/#!documentation/models …
jaumard
  • 8,202
  • 3
  • 40
  • 63
0
votes
0 answers

Update associated field in Waterline/Sails without affecting other fields

I notice that multiple requests to a record causes writes to be possibly overwritten. I am using Mongo btw. I have a schema like: Trip { id, status, tagged_friends } where tagged_friends is an association to Users collection When I make 2…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
0
votes
1 answer

Waterline JS destroy model based on parent

I have a schema like: Question { id, user, ... } Answer { id, user, question, ... } I want to allow both user who posted answer or the parent question to delete an answer. How can I do it? I want to remove an Answer if the userId param is either…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
0
votes
1 answer

How do I release a pool connection from a model?

I want to read a big JSON file (this to be precise), iterate over it, check which are new entries and save or update as necessary. Doing this with sails, and sails mysql I found out that the whole process slows down the first time and if I try to…
tic2000
  • 66
  • 5
0
votes
1 answer

Sails server fails to start. Probably due to association in models

I am using Sails for a project. I used Chrome POSTMAN to create a model instance. After that, I can not start sails server. The error message is attached below. I realized that this is due to association I have in the model. How can I use POSTMAN to…
windchime
  • 1,253
  • 16
  • 37
0
votes
1 answer

Boolean attribute for Waterline model

I have a MySQL database and a Waterline model for a fairly simple record: Todo. It's straight-forward as we're using it for proof-of-concept for a Sails.js API. CREATE TABLE `Todo` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `TodoItem`…
YtramX
  • 172
  • 10
0
votes
2 answers

Sails.js - protect blueprint associations using policies

In order to create a many-to-many association between models, I use the blueprints to access something like: /api/item/1/tags/2 How can I protect this action using policies? This action doesn't seem to fit any of the find/create/update/destroy…
Ronen Teva
  • 1,345
  • 1
  • 23
  • 43
0
votes
1 answer

Cannot construct the Router in Backbone app

I am building an application with the fiddle here for self teaching with Backbone and node.js express and mongodb. I have a problem with constructing the Router I have defined by extending from Backbone.Router. In js console I have the error…
sçuçu
  • 2,960
  • 2
  • 33
  • 60
0
votes
1 answer

How to add a new field in sails.js/waterline on "create"?

My School model has a name, address, etc. and an owner which is a User object. School.js module.exports = { attributes: { name: { type: 'string', required: true }, address: { type: 'string' }, owner: { …
Chris F.
  • 493
  • 5
  • 17
0
votes
1 answer

ER_BAD_FIELD_ERROR when using Waterline ORM in Sails.js

I'm getting the following error when trying to call .create() on a model from a Sails.js controller. Here is my model, TemperatureReading.js: module.exports = { connection: 'mainDatabase', tableName: 'TemperatureReading', attributes: { …
kibowki
  • 4,206
  • 16
  • 48
  • 74
0
votes
1 answer

Sorting in asynchronous code

I am working on a system to match Volunteers who have FreeUnits (slots of time when they are free) to WorkUnits (slots of times per which X number of volunteers are required). The algorithm I wish to implement is sort WorkUnits by possible FreeUnits…
kmangutov
  • 3
  • 2