1

是否可以配置表的安全性,只允许数据库表中条目的某些用户(所有者)修改条目?

例如,在笔记应用程序中,每个笔记都分配给拥有该笔记的用户列表。所有用户都应该能够看到所有笔记,但只有该节点的所有者才能编辑/删除该笔记条目。

我只找到了过滤谁可以看到笔记但不能编辑笔记的解决方案。

4

1 回答 1

2

您将需要为此创建一个操作。转到操作表。选择更新期间事件。这是取自https://github.com/backand/todos-with-users的示例

// if the current user has an *Admin* role then he is allowed to update a todo for other users
  if (userProfile.role == "Admin")
    return {};

  if (!dbRow.created_by)
      throw new Error('Todo with no creator can\'t be updated.');

  // do not allow users to change the created by field 
  if (dbRow.created_by !=  userInput.created_by)
      throw new Error('You can\'t change the creator of the todo.');

  // do not allow non *Admin* users to change the creator of the todo 
  if (dbRow.created_by != userProfile.userId)
      throw new Error('You can only update your own todo.');
  return {};
于 2016-02-21T09:00:55.550 回答