Code Monkey home page Code Monkey logo

Comments (5)

zackyang000 avatar zackyang000 commented on August 19, 2024

是的, 这是我之前挖的一个坑 T_T

做的时候就知道可能有 bug, 不过当时由于没有使用 before 这个 api, 所以就没有去测试它.

0.7 版中将解决这个问题. (预计本周完成) 目前请暂时使用 after.

另外, 设计 before 主要是为了进行一些验证, 如果不符合规则等, 在最后 return false 将阻止相应的操作执行. after 主要是为了可能在插入数据之后还有一些后续操作. 比如要重新计算其他 resource 的某个字段, 或可能要做一些 log. 因为 before 会阻塞整个请求, 所以建议如果只是记录 log 的话在 after 中进行, 因为它是异步的, 当 REST 的操作完成后将直接返回给客户端, 剩下的操作将在返回后执行.

这一点没有在文档中进行说明, 表示抱歉. 之后我会添加到文档中.

感谢关注.

from node-odata.

zackyang000 avatar zackyang000 commented on August 19, 2024

Fixed it on 969ab5d.

from node-odata.

suiandtang avatar suiandtang commented on August 19, 2024

我的实际意图是要记录 每次操作的服务器处理耗时。
设计在before中放入开始时间,在after中用(当前时间-开始时间)计算出方法的总耗时,是否可行?
或者有其他更好的记录方式吗

from node-odata.

zackyang000 avatar zackyang000 commented on August 19, 2024

可以考虑使用 response-time 中间件.

from node-odata.

suiandtang avatar suiandtang commented on August 19, 2024

谢谢,已经搞定

from node-odata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.