Strapi:是否可以跟踪用户修改内容? [英] Strapi : is it possible to track users modifying content?

查看:69
本文介绍了Strapi:是否可以跟踪用户修改内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在对 Strapi 进行一些研究,以便在其上构建我的 API,我想知道是否可以在 JSON 中公开一个字段,该字段将包含有关负责对特定的最后修改负责的用户的信息内容 ?

I'm currently doing some research on Strapi in order to build my API on it, and I was wondering if it's possible to expose in the JSON a field that would contain information about the user responsible for the last modification on a particular content ?

我知道 API 默认在 JSON 对象中公开一个updatedAt"字段,其中包含上次更新的日期时间,但据我所知,当数据发送到数据库以进行持久化时,该字段由数据库处理?

I know the API exposes an "updatedAt" field in the JSON object by default that contains the datetime it was last updated, but as I understand it this field is handled by the database when the data is sent to it for persistance ?

任何帮助将不胜感激!非常感谢.

Any help would be greatly appreciated ! Thanks a lot.

推荐答案

截至 2020 年,您可以在两个地方找到更新记录的人:

As of 2020, you can find the person who updated the record, in two places:

// ./api/yourmodelname/models/yourmodelname.js

modules.exports = {
  async afterUpdate(modifications, filter, resultData) {
    console.log(modifications.updated_by) // Full user object of editing Strapi user
    console.log(resultData.updated_by)    // User ID of editing Strapi user
  }
}

这篇关于Strapi:是否可以跟踪用户修改内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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