Results 1 to 2 of 2

Thread: Using SQL to query any Store

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Dallas, TX
    Vote Rating

    Default Using SQL to query any Store

    To whomever likes SQL:

    Using the SequelSphereDB engine, I was able to create an '' Class that allows you to execute SQL against any data Store(s) managed by Here is some sample usage code:

    var store = Ext.create('', {
        storeId: "EmplDeptQuery",
        sql: "SELECT empl_id,, age, as dept_name " +
             "  FROM empl e " +
             "  JOIN dept d " +
             "    ON e.dept_id = d.dept_id " +
             " WHERE age > 20"
    In the above example, 'Empl' is an, and 'Dept' is an

    When SQL is executed, it all occurs in the browser, using the SequelSphereDB engine to parse and execute the SQL.

    The Code for can be found here:

    And an example app showing integration with a Grid and Chart along with more sample code can be found here:

    As one last example, consider this: let's get the departments whose managers are younger than the average age of the employees in the department.

    var store = Ext.create('', {
        storeId: "EmplDeptQuery",
        sql: "SELECT, count(*) as nbr_empls, avg(e.age) as age " +
             "     , as mgr_name, m.age as mgr_age " +
             "  FROM dept d " +
             "  JOIN empl e ON e.dept_id = d.dept_id " +
             "  JOIN empl m ON m.empl_id = d.mgr_id " +
             " GROUP BY,, m.age " +
             "HAVING m.age <= avg(e.age) " +
             " ORDER BY avg(e.age) - m.age desc"
    All feedback is welcome. Please let me know if there are other ways you think SQL could be incorporated with ExtJS.


    - John Fowler
    SequelSphere: An HTML5 / JavaScript Relational Database

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    Nice contribution!
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2

    Think my support is good? Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts