简体   繁体   English

如何使用 React 查询 Moralis 角色?

[英]How to query Moralis roles with React?

I'm checking out Moralis for the first time today.我今天第一次检查 Moralis。 Saw a few of the tutorials and read the documentation.看了一些教程并阅读了文档。 Currently, I'm trying to query the Roles (_Role) but all I get is an empty array.目前,我正在尝试查询角色(_Role),但我得到的只是一个空数组。

const { fetch: getStaffRole } = useMoralisQuery('_Role');

async function Check() {

  const q = new Moralis.Query('_Role');
  const r = await q.first();
  console.log('w functions:', r); //returns undefined

  const r2 = await getStaffRole();
  console.log('w hooks:', r2); //returns Array []

}

Code snippet of the query, Stack doesn't allow me to directly upload the image here.查询的代码片段,堆栈不允许我在这里直接上传图像。

—> Table permissions, table, & console logs —> 表权限、表和控制台日志

You need to specify Moralis.Role and to add userMasterKey您需要指定 Moralis.Role 并添加 userMasterKey

  const result = await new Moralis.Query(Moralis.Role)
  .equalTo("name", 'admin')
  .first({ useMasterKey: true });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM