Does the QueryChainer Util still exist?

393 views
Skip to first unread message

justin hyland

unread,
Dec 11, 2015, 2:42:37 PM12/11/15
to Sequelize
I was following along on this article, which I realize is a few years old, but it's still pretty helpful, I learned a bit from it.

I'm stuck on an issue, that would be solved perfectly by the Query Series section in that article. It states that theres a Sequelize.Utils.QueryChainer() that will execute multiple queries in order, then return all the results, which is awesome!

Heres the example code in the article:
new Sequelize.Utils.QueryChainer()
 
.add(User, 'find', [id])
 
.add(Task, 'findAll')
 
.error(function(err) { /* hmm not good :> */ })
 
.success(function(results) {
   
var user = results[0];
   
var tasks = results[1];
   
// do things with the results
 
});

So I tried to implement the QueryChainer in my code, I made it about as simple as it gets, here it is:
new Sequelize.Utils.QueryChainer()
   
.add(People, 'findAll')
   
.add(People, 'findAll', {id: 119})
   
.error(function(err) {  })
   
.success(function(results) {
       
console.log('Results',results);
   
});


Now, when I execute that code, here is the result I get in the console:
new Sequelize.Utils.QueryChainer()
^
TypeError: Sequelize.Utils.QueryChainer is not a function
    at Object.<anonymous> (/Users/jhyland/Documents/scripts/js/node/test/sequelize-query_promise.js:59:1)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3

I couldn't find too much out there on this, and the Sequelize documentation is a little difficult to navigate through.. so I was wondering if there was just a new version of this out or something?

Thanks!

Mick Hansen

unread,
Dec 11, 2015, 2:46:20 PM12/11/15
to justin hyland, Sequelize
The QueryChainer has been gone since 2.0 was released.
Simply using promises should solve everything you need.
--
Mick Hansen
@mhansendev
mhansen.io
Reply all
Reply to author
Forward
0 new messages