2

I am currently using juggling db with NodeJS for ORM. I now need to do some reporting, which involves joining data from several tables using arbitrary SQL with SUM and GROUP BY too. How would I do this using the jugglingdb framework, and get a list of objects containing data from several columns.

nwaltham
  • 2,067
  • 1
  • 22
  • 40

1 Answers1

4

You can access to the query function from the mysql package using the adapter client:

var Schema = require('jugglingdb').Schema;
var schema = new Schema('mysql', {
 // your config
});

schema.client.query('your very wild query', function(err, data) {
 // data will be an Array of Objects if no error
});

Actually this is a direct call to the query function of node-mysql package

  • So what does the very wild query actually look like? It doesn't look like "SELECT * FROM TABLE_NAME WHERE id=1", does it? I've been trying to create different queries, but it doesn't seem to be firing them off... – incutonez Aug 29 '13 at 15:05
  • 1
    Nevermind... I'm using the postgres adapter, and instead of `schema.client.query`, I had to user `schema.adapter.query`. – incutonez Aug 29 '13 at 15:46
  • @incutonez I have used `schema.adapter.query`. But it shows that `function(err,data){ //funtion body } has no method 'pop'` – Rohit Mar 13 '14 at 12:00
  • No method `pop`? I'm not quite sure what you're using it for or how... does `schema.client.query` work for you? – incutonez Mar 13 '14 at 13:04