sails.js:模型的生命周期回调:它们是否支持beforeFind和afterFind? [英] sails.js: Lifecycle callbacks for Models: Do they support beforeFind and afterFind?

查看:79
本文介绍了sails.js:模型的生命周期回调:它们是否支持beforeFind和afterFind?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sails.js中,模型支持生命周期回调,以进行验证,创建,更新和销毁.

In sails.js, Models support lifecycle callbacks for validate, create, update and destroy.

是否也支持find()或查询的回调?像beforeFind()和afterFind()一样?

Is there support for callbacks for find() or query as well? Like beforeFind() and afterFind()?

想法是一样的.我想在查询运行前或查询运行后验证/修改参数.

The idea is same. I would want to validate / modify parameters before the query is run or after the query is run.

有什么想法吗?

推荐答案

在撰写本文时,它不支持这些请求,但是它们是请求请求

As of writing this it does NOT support these requests, however their is a pull request https://github.com/balderdashy/waterline/pull/525

您可以同时使用策略来做到这一点.

You can use policies to do this in the mean time.

这篇关于sails.js:模型的生命周期回调:它们是否支持beforeFind和afterFind?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆