feathers-sequelize

Using feathers-client and sequelize many-to-many relation

旧时模样 提交于 2021-02-10 18:18:10
问题 I'm trying to get data from an n:m association using feathers. I'm using react for my front-end and connecting to feathers using the feathers-client and socketio. //connection string where the feathers api is running const host = 'http://localhost:3030'; const socket = io(host, { transports: ['websocket'], forceNew: true }); // construct feathers app export const client = feathers() .configure(hooks()) .configure(auth({ storage: window.localStorage })) .configure(socketio(socket)); But when I

How to query many to many relation in sequelize

女生的网名这么多〃 提交于 2019-12-22 07:05:30
问题 I've been using feathersjs/nodejs over postgres db via sequelize. In my db i have Users table and Events table. They are twice in relation: events.belongsTo(models.users, { foreignKey: { name: 'creatorId', allowNull: false }, onDelete: 'CASCADE', as: 'creator' }); events.belongsToMany(models.users, { through: 'event_participants', as: 'participants', foreignKey: 'eventId', otherKey: 'userId' }); models.users.belongsToMany(events, { through: 'event_participants', as: 'events' }); Everything

Feathers.js / Sequelize -> Service with relations between two models

空扰寡人 提交于 2019-12-10 04:17:15
问题 I've got feathers.js functioning with mysql via sequelize. This is working, I can collect data from tables. Next step is to define 'joins' in the models. I have a table with a column 'status_id' and 'country_id'. These columns reference to an id in a metadata table. In SQL I would right: SELECT status.description, country.description, detail FROM details INNER JOIN metadata status ON (details.status_id = status.id AND status.type = 'status' INNER JOIN metadata country ON (details.country_id

How to query many to many relation in sequelize

我的梦境 提交于 2019-12-05 09:39:41
I've been using feathersjs/nodejs over postgres db via sequelize. In my db i have Users table and Events table. They are twice in relation: events.belongsTo(models.users, { foreignKey: { name: 'creatorId', allowNull: false }, onDelete: 'CASCADE', as: 'creator' }); events.belongsToMany(models.users, { through: 'event_participants', as: 'participants', foreignKey: 'eventId', otherKey: 'userId' }); models.users.belongsToMany(events, { through: 'event_participants', as: 'events' }); Everything works just fine, table is created and with include im getting users inside of event as participants.

Feathers.js / Sequelize -> Service with relations between two models

半城伤御伤魂 提交于 2019-12-05 05:49:45
I've got feathers.js functioning with mysql via sequelize. This is working, I can collect data from tables. Next step is to define 'joins' in the models. I have a table with a column 'status_id' and 'country_id'. These columns reference to an id in a metadata table. In SQL I would right: SELECT status.description, country.description, detail FROM details INNER JOIN metadata status ON (details.status_id = status.id AND status.type = 'status' INNER JOIN metadata country ON (details.country_id =country.id AND country.type = 'country') This metadata table won't be big in this case so hence this