【问题标题】:How to query Moralis roles with React?如何使用 React 查询 Moralis 角色?
【发布时间】:2022-07-01 15:15:53
【问题描述】:

我今天第一次检查 Moralis。看了一些教程并阅读了文档。目前,我正在尝试查询角色 (_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

【问题讨论】:

    标签: javascript reactjs next.js moralis


    【解决方案1】:

    您需要指定 Moralis.Role 并添加 userMasterKey

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

    【讨论】:

      猜你喜欢
      • 2018-12-03
      • 2014-12-30
      • 2021-09-25
      • 2023-02-14
      • 1970-01-01
      • 2021-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多