Can't get a userGroup having its name... Is it relevant to use Qt Enginio module ?



  • Hi,

    I am trying to get the id of a group given its name. Quite simple, no ?
    I have thus written this function :

    function getGroupId1(groupName){
            var groupQuery = client.query({ "query": { "name" : groupName }}, Enginio.UsergroupOperation)
            groupQuery.finished.connect(function(){
                if (groupQuery.errorType !== EnginioReply.NoError) {
                    console.log( groupQuery.errorString);
                    session.authStatus = groupQuery.errorString
                } else if (groupQuery.data.results.length === 0 ){
                    console.log("group not found :" + groupName);
                    session.authStatus = qsTr("Group '%1' not found").arg(groupName)
                } else {
                    console.log("Group ID is :"+groupQuery.data.results[0].id);
                }
            })
        }
    

    Unfortunately, If I call this function whith a groupName I never get the group id !

    So I have tried to filter the group by name manually and this is working well :

    function getGroupId2(groupName){
        var groupQuery = client.query({}, Enginio.UsergroupOperation)
        groupQuery.finished.connect(function(){
            if (groupQuery.errorType !== EnginioReply.NoError) {
                console.log( groupQuery.errorString);
                session.authStatus = groupQuery.errorString
            } else if (groupQuery.data.results.length === 0 ){
                console.log("group not found :" + groupName);
                session.authStatus = qsTr("Group '%1' not found").arg(groupName)
            } else {
                for (var i = 0; i < groupQuery.data.results.length; i++){
                    if (groupQuery.data.results[i].name === groupName)
                        console.log("Found group ID : "+groupQuery.data.results[i].id);
                    else
                        console.log("Rejecting group name : "+groupQuery.data.results[i].name);
                }
            }
        })
    }
    

    And this one works well !

    So it seems that my query used in getGroupId1could be not correct despite it is exactly the same as the one mentionned in the documentation...

    Actually I am wondering if the enginio qt module is functional as :

    Maybe using the enginio Qt module is not the way to go..if so, what workaround would you propose ?
    Best regards.


Log in to reply
 

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