Tag: 羽毛钩

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

我想在插入数据库之前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 […]