Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] Quering Enginio with QML
QtWS25 Last Chance

[SOLVED] Quering Enginio with QML

Scheduled Pinned Locked Moved Mobile and Embedded
qmlenginioquery
25 Posts 5 Posters 10.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by guidupas
    #1

    Hello all!

    I need to query data from enginio databse and use it in a ComboBox, but I could not figure out how to do it. Could someone help me?

    Thanks

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you took a look at getting started Enginio QML ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      guidupasG 1 Reply Last reply
      0
      • C Offline
        C Offline
        clochydd
        wrote on last edited by
        #3

        Hi guidupas,

        here's a small snippet showing how to query enginio by using EnginioModel:

        
        EnginioClient {
        	id: client
        	backendId: "myID..."
        }
        
        
        EnginioModel {
        	id: enMod
        	client: client
        	query: 
        		{
        		"objectType" : "objects.myobject",
        		"sort": [{"sortBy":"updatedAt","direction":"desc"}],
        		"query": {"updatedAt": {"$gt": {"$type": "time","$value": getYesterday()}}},
        		"limit": 15
        		}
        }
        
        
        function getYesterday( ) {
        	var today = new Date();
        	today.setDate(today.getDate()-5)
        	return Qt.formatDate(today, "yyyy-MM-ddT00:00:00Z");
        }
        
        

        You may use all the objects in the EnginioModel enMod in your script:

        text: updatedAt 
        

        etc.

        Hope, it helps

        guidupasG 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Did you took a look at getting started Enginio QML ?

          guidupasG Offline
          guidupasG Offline
          guidupas
          wrote on last edited by
          #4

          @SGaist

          Hello!

          Thanks for the reply

          Yes, I have seem the link you suggested, but it just show how to insert data and my difficult here is how to get and use the data from Enginio.

          Att.
          Guilherme Cortada Dupas

          1 Reply Last reply
          0
          • C clochydd

            Hi guidupas,

            here's a small snippet showing how to query enginio by using EnginioModel:

            
            EnginioClient {
            	id: client
            	backendId: "myID..."
            }
            
            
            EnginioModel {
            	id: enMod
            	client: client
            	query: 
            		{
            		"objectType" : "objects.myobject",
            		"sort": [{"sortBy":"updatedAt","direction":"desc"}],
            		"query": {"updatedAt": {"$gt": {"$type": "time","$value": getYesterday()}}},
            		"limit": 15
            		}
            }
            
            
            function getYesterday( ) {
            	var today = new Date();
            	today.setDate(today.getDate()-5)
            	return Qt.formatDate(today, "yyyy-MM-ddT00:00:00Z");
            }
            
            

            You may use all the objects in the EnginioModel enMod in your script:

            text: updatedAt 
            

            etc.

            Hope, it helps

            guidupasG Offline
            guidupasG Offline
            guidupas
            wrote on last edited by
            #5

            @clochydd

            Hello!

            Thanks for the reply!

            The code you posted helped a lot, but I could not, yet, use the data. When I try to use it like you suggested: text: updatedAt it shows me the message:

            qrc:/main.qml:117: ReferenceError: updatedAt is not defined

            Here is my code. I will became grateful if you could help me:

            EnginioClient {
                    id: clienteEnginio
                    backendId: "MyBackEnd"
                }
            
            EnginioModel {
                    id: paisEnginioModel
                    client: clienteEnginio
            
                    query: {
                        "objectType" : "objects.pais",
                        "sort": [{"sortBy":"updatedAt","direction":"desc"}],
                        "query": {"updatedAt": {"$gt": {"$type": "time","$value": getYesterday()}}},
                        "limit": 15
                    }
                    property string text: updatedAt
                }
            
                function getYesterday( ) {
                    var today = new Date();
                    today.setDate(today.getDate()-5)
                    return Qt.formatDate(today, "yyyy-MM-ddT00:00:00Z");
                }
            

            Att.
            Guilherme Cortada Dupas

            1 Reply Last reply
            0
            • C Offline
              C Offline
              clochydd
              wrote on last edited by
              #6

              Hello,

              in my example I used updatedAt as this is one of the internal properties.
              Therefore it is not necessary to declare it as a property.
              Instead of it you may use any of the properties from your enginio object.
              If you have "name" you may use it without any further declaration in your model.

              Just try to delete the entry "property string..." and try to use it with your clienteEnginio.

              guidupasG 1 Reply Last reply
              0
              • C clochydd

                Hello,

                in my example I used updatedAt as this is one of the internal properties.
                Therefore it is not necessary to declare it as a property.
                Instead of it you may use any of the properties from your enginio object.
                If you have "name" you may use it without any further declaration in your model.

                Just try to delete the entry "property string..." and try to use it with your clienteEnginio.

                guidupasG Offline
                guidupasG Offline
                guidupas
                wrote on last edited by
                #7

                @clochydd

                It returned this:
                Cannot assign to non-existent property "text"

                Here is the code:

                EnginioModel {
                        id: paisEnginioModel
                        client: clienteEnginio
                        /*query: {
                            "objectType" : "objects.pais",
                            "sort": [{"sortBy" : "nome","direction" : "desc"}],
                            "query": {"nome": {"$gt": {"$type" : "string","$value": "Brasil"}}},
                            "limit": 15
                        }*/
                
                        query: {
                            "objectType" : "objects.pais",
                            "sort": [{"sortBy":"updatedAt","direction":"desc"}],
                            "query": {"updatedAt": {"$gt": {"$type": "time","$value": getYesterday()}}},
                            "limit": 15
                        }
                
                        text: updatedAt
                    }
                

                Att.
                Guilherme Cortada Dupas

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  clochydd
                  wrote on last edited by
                  #8

                  Did you assign your enginioModel to your ComboBox?

                  ComboBox {
                      width: 200
                      model: paisEnginioModel
                  }
                  
                  guidupasG 1 Reply Last reply
                  0
                  • C clochydd

                    Did you assign your enginioModel to your ComboBox?

                    ComboBox {
                        width: 200
                        model: paisEnginioModel
                    }
                    
                    guidupasG Offline
                    guidupasG Offline
                    guidupas
                    wrote on last edited by
                    #9

                    @clochydd

                    Yes, here it is:

                    EnginioClient {
                            id: clienteEnginio
                            backendId: "MyId"
                        }
                        EnginioModel {
                            id: paisEnginioModel
                            client: clienteEnginio
                            query: {
                                "objectType" : "objects.pais",
                                "sort": [{"sortBy":"updatedAt","direction":"desc"}],
                                "query": {"updatedAt": {"$gt": {"$type": "time","$value": getYesterday()}}},
                                "limit": 15
                            }
                    
                            text: updatedAt
                        }
                        ComboBox {
                            id: comboBox1
                    
                            model: paisEnginioModel
                        }
                    

                    It returns this message:
                    QQmlApplicationEngine failed to load component
                    qrc:/main.qml:70 Cannot assign to non-existent property "text"

                    Att.
                    Guilherme Cortada Dupas

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      clochydd
                      wrote on last edited by
                      #10

                      You should not use text: updateAt inside your model.
                      (In my first post this was only meant as an example...)

                      By assigning the model to the ComboBox the properties from the model are part of the ComboBox.

                      If you look at the ComboBox example:

                      ComboBox {
                          width: 200
                          model: [ "Banana", "Apple", "Coconut" ]
                      }
                      

                      [ "Banana", "Apple", "Coconut" ] will be replace by your paisEnginioModel.

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        clochydd
                        wrote on last edited by clochydd
                        #11

                        Hi guidupas,

                        until now I didn't use a ComboBox with QML and Enginio, so I've made this small example:

                        Assume, we have a collection objects.contacts with custom properties name and address:

                        {
                          "name": "Peter",
                          "address": "Somewhere"
                        }
                        {
                          "name": "Peter",
                          "address": "Anywhere"
                        }
                        

                        and we want to see the addresses for all Peters in the ComboBox:

                        import QtQuick 2.3
                        import QtQuick.Controls 1.2
                        import Enginio 1.0
                        
                        Rectangle {
                            width: 500; height: 200
                        
                            EnginioClient {
                                id: client
                                backendId: "myBackendID..."
                                onError: console.log(reply.errorCode + ": " + reply.errorString)
                            }
                            EnginioModel {
                                id: eModel
                                client: client
                                query: {
                                    "objectType": "objects.contacts",
                                    "query" : {"name": "Peter"}
                                }
                            }
                            ComboBox {
                                model: eModel
                                textRole: "address"
                        
                            }
                        }
                        

                        And your ComboBox will contain:
                        Somewhere
                        Anywhere

                        Hope, it helps a bit...

                        guidupasG 2 Replies Last reply
                        0
                        • C clochydd

                          Hi guidupas,

                          until now I didn't use a ComboBox with QML and Enginio, so I've made this small example:

                          Assume, we have a collection objects.contacts with custom properties name and address:

                          {
                            "name": "Peter",
                            "address": "Somewhere"
                          }
                          {
                            "name": "Peter",
                            "address": "Anywhere"
                          }
                          

                          and we want to see the addresses for all Peters in the ComboBox:

                          import QtQuick 2.3
                          import QtQuick.Controls 1.2
                          import Enginio 1.0
                          
                          Rectangle {
                              width: 500; height: 200
                          
                              EnginioClient {
                                  id: client
                                  backendId: "myBackendID..."
                                  onError: console.log(reply.errorCode + ": " + reply.errorString)
                              }
                              EnginioModel {
                                  id: eModel
                                  client: client
                                  query: {
                                      "objectType": "objects.contacts",
                                      "query" : {"name": "Peter"}
                                  }
                              }
                              ComboBox {
                                  model: eModel
                                  textRole: "address"
                          
                              }
                          }
                          

                          And your ComboBox will contain:
                          Somewhere
                          Anywhere

                          Hope, it helps a bit...

                          guidupasG Offline
                          guidupasG Offline
                          guidupas
                          wrote on last edited by
                          #12

                          @clochydd

                          It worked fine.

                          Thank you very much. It helped a lot.

                          Att.
                          Guilherme Cortada Dupas

                          1 Reply Last reply
                          0
                          • C clochydd

                            Hi guidupas,

                            until now I didn't use a ComboBox with QML and Enginio, so I've made this small example:

                            Assume, we have a collection objects.contacts with custom properties name and address:

                            {
                              "name": "Peter",
                              "address": "Somewhere"
                            }
                            {
                              "name": "Peter",
                              "address": "Anywhere"
                            }
                            

                            and we want to see the addresses for all Peters in the ComboBox:

                            import QtQuick 2.3
                            import QtQuick.Controls 1.2
                            import Enginio 1.0
                            
                            Rectangle {
                                width: 500; height: 200
                            
                                EnginioClient {
                                    id: client
                                    backendId: "myBackendID..."
                                    onError: console.log(reply.errorCode + ": " + reply.errorString)
                                }
                                EnginioModel {
                                    id: eModel
                                    client: client
                                    query: {
                                        "objectType": "objects.contacts",
                                        "query" : {"name": "Peter"}
                                    }
                                }
                                ComboBox {
                                    model: eModel
                                    textRole: "address"
                            
                                }
                            }
                            

                            And your ComboBox will contain:
                            Somewhere
                            Anywhere

                            Hope, it helps a bit...

                            guidupasG Offline
                            guidupasG Offline
                            guidupas
                            wrote on last edited by
                            #13

                            @clochydd

                            Hello @clochydd !

                            I heard that Enginio is going to be deprecated. Do you know if this is true?

                            Cheers.

                            Att.
                            Guilherme Cortada Dupas

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Hi,

                              AFAIK, the talk is about the client library, not the service

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                clochydd
                                wrote on last edited by
                                #15

                                Hi SGaist,

                                thanks for your comment - is there any information available in the forum or elsewhere? I wonder about the consequences, if the client library will be deprecated.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  Currently I only saw this on the mailing list. If that be the case, it will be properly announced. The deprecation just means that there won't be further development on the client part except security related stuff. The code itself isn't going to disappear.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • CharbyC Offline
                                    CharbyC Offline
                                    Charby
                                    wrote on last edited by
                                    #17

                                    I was just starting to learn engin.io but according to the 5.6 roadmap the module will be deprecated http://wiki.qt.io/New_Features_in_Qt_5.6). What would be the recommanded way to communicate with an EDS backend from a qml mobile app? Even if the api will remains I feel it is not advisable to start a new project with an ingoing deprecated module...

                                    1 Reply Last reply
                                    0
                                    • C Offline
                                      C Offline
                                      clochydd
                                      wrote on last edited by
                                      #18

                                      @Charby
                                      You are absolutely right! And it seems to be quite strange to see Digia propagating Enginio on their current web presence while planning to remove Qt Enginio...

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #19

                                        From https://developer.qtcloudservices.com/eds/references/sdk-libraries It looks like there's something in the work.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        S 1 Reply Last reply
                                        0
                                        • SGaistS SGaist

                                          From https://developer.qtcloudservices.com/eds/references/sdk-libraries It looks like there's something in the work.

                                          S Offline
                                          S Offline
                                          Sajad Manal
                                          wrote on last edited by
                                          #20

                                          @SGaist Sir I am new to qt . I didn't know where to ask to I am givingmy question here:

                                          I downloaded qt-opensource-linux-x86-5.4.1.run but how to install it on ubuntu 14.04LTS?

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved