Tag: sequelize

如何对待羽毛球内的承诺?

我想在插入数据库之前validation数据。 Feathersjs的方式是通过使用钩子。 在插入一组权限之前,我必须考虑用户post提供的数据的完整性。 我的解决scheme是find与用户提供的数据相关的所有权限。 通过比较列表的长度,我可以certificate,如果数据是正确的。 钩子的代码贴在下面: const permissionModel = require('./../../models/user-group.model'); module.exports = function (options = {}) { return function usergroupBefore(hook) { function fnCreateGroup(data, params) { let inIds = []; // the code in this block is for populating the inIds array if (inIds.length === 0) { throw Error('You must provide the permission List'); } //now […]

Feathers.js / Sequelize – >服务与两个模型之间的关系

我有通过sequelize与MySQL运行的羽毛。 这是工作,我可以从表中收集数据。 下一步是在模型中定义“连接”。 我有一个列'status_id'和'country_id'的表。 这些列引用元数据表中的ID。 在SQL中,我会对: 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') 这个元数据表在这种情况下不会很大,所以这个方法就是这样。 它确实给我需要的灵活性。 我需要做些什么才能在feathters.js中做到这一点?