MoralisWeb3 / issue-tracker

25 stars 7 forks source link

Relational query not returning data #67

Closed jermay closed 2 years ago

jermay commented 3 years ago

I think the relation query docs are incorrect https://docs.moralis.io/objects#relational-data

There is no "success" callback function defined on ParseQuery.find() see the API docs here: http://parseplatform.org/Parse-SDK-JS/api/3.2.0/Parse.Query.html#find

When I try using promises in the Moralis Dashboard JS Console it returns no data. In the Browser the data and relations are defined and can be navigated through.

image

image

let character = await new Parse.Query("Character")
  .equalTo("name", "Friar")
  .first();
console.log(character);

const inventoryItems = await character.relation("inventory").query().find();
console.log(inventoryItems);

image

nconfrey commented 2 years ago

Any update on this? Also finding that queries on relations are not returning anything:

let relation = page.relation("posts")
      relation.query().find({
        success: function (list) {
          console.log("connection page successfully found posts:", posts)
          setPosts(posts)
          setIsLoading(false)
        }, error: function(error) {
          console.log("ERROR: ", error)
        }
      });

Never hits the success callback.

ivan-liljeqvist commented 2 years ago

This is solved I think long time ago

for all questions and discussions please use forum https://forum.moralis.io

nconfrey commented 1 year ago

Hello past Nick, the Moralis documentation is wrong here, that's why you got stuck. Try calling find() and then waiting for the promise to resolve:

const connectionsRelation = currentAccount.relation("Connections")
    connectionsRelation.query().find().then(function (results) {
      setConnections(results)
    })
      .catch(function (error) {
        console.log(error)
      })