michaelwittig / node-q

Q interfacing with Node.js
MIT License
52 stars 14 forks source link

Calling upd with tablular data #41

Closed wwarby closed 5 years ago

wwarby commented 5 years ago

Apologies if this is my mistake because I'm very new to node-q (and q itself) but I'm struggling to send tabular data to the upd function (or any function for that matter) as an argument to the k function rather than as a raw string. Specifically:

This works:

conn.k('upd[`demoTable; ([]demoSymbol:`a`b)];');

But this does not:

conn.k('upd', nodeq.symbol('demoTable'), {
  demoSymbol: nodeq.symbols(['a', 'b'])
});

The latter give a 'type error response.

I've tried a few variations of this without success. Is what I'm trying to do actually possible with node-q? All I'm really aiming for is to insert data into a table without composing the raw q string myself.

michaelwittig commented 5 years ago

The reason might be that you send a dict instead of a table in the second example. If you flip the dict you get a table.

Unfortunately, there is no typed support for tables. I haven't implemented when I was working on this: https://github.com/michaelwittig/node-q/blob/master/lib/typed.js#L265

wwarby commented 5 years ago

Thanks so much Michael, that works perfectly. I'd tried a lot of things, but that wasn't one of them. For the benefit of anyone else who encounters this problem, this is the correct syntax:

conn.k('upd', nodeq.symbol('demoTable'), [
  { demoSymbol: nodeq.symbol('a') },
  { demoSymbol: nodeq.symbol('b') }
], callback);