Include referenced objects in a query



  • Hi!

    I have an object type A with a reference to another object type B. I would like to query some objects of type A and include the referenced objects of type B. Does anybody have a simple example for this? How can I access properties of the referenced objects?

    Best regards,
    Oliver.



  • Hi Oliver

    I think you will have to provide some additional information as what you want to do is not entirely clear.

    If you simply want to get hold of A's (member?) reference B, then a basic getter will do:

    @
    const B& A::getB() const
    {
    return b;
    }
    @

    From your calling function, you will then need something like this:

    @
    a.getB().doSomethingSpecificToB();
    @



  • Hi!

    You are right. I should have been more precise. Sorry.

    I am writing an app with qml and I use enginio as backend. I have a property "ref" in object type "typeA" which is a reference to another object type "typeB". I would like to query some objects of typeA and include the referenced objects of typeB.

    In the meantime, I got help from enginio. The following code works with enginio 0.3.0.

    @
    QueryOperation {
    id: queryOperation
    model: myModel
    objectTypes: ["objects.typeA"]
    include: {"ref": {}}
    client: client
    onFinished: {
    }
    onError: {
    }
    }
    @

    You have to ensure that "read" is set in the ACL.

    Best regards,
    Oliver.



  • Ah, I see...Afraid I'm not going to be much help for you now, however, as I have never used QML before. Hopefully someone will come around soon! :)

    (I'm sorry, I never noticed that your thread was started in the Enginio group :D )


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.