Search code examples
postgresqlfeathersjsfeathers-sequelizefeathers-hookfeathers-service

How does feathers sequelize work


I'm using angular2 on frontend, node/feathers on backend over Postgres (sequelize) db.

  1. On backend I have events service on ".../events" route, and I'm trying to reach data from db, it works fine when I want to retrieve all events so I just make request on this route.. or when I want to retrieve just one event with certain id (make request on "../events/>>id<<). But how to get data by other attributes, for example I have user and its in association with event one to many, so how would I retrieve all events for one user (search by user id, not by events id). Or any other attribute, for example by name, return all events with certain name. How would that work, any code example?

  2. In events model I have relation with user as one to many (event has creator) and I made that connection as events.belongsTo(user). How can I add that this same event has also many to many relation with users cause it has also attribute "participants" as users that are also included into this event, and every user can participate or own many events.


Solution

    1. Found it myself, just add ?attribute=value... so if i want all events owned by user with id 1... it would be ".../events?userId=1 ... and this would return me all the events with userId=1... same goes with any other attribute –