0

After an hour of trying various syntaxes and npm modules:

How would I achieve yielding a call to the elasticsearch client? I'm looking at something like this:

var res = yield *client.get({
  index: index,
  type: type,
  id: id,
  ignore: [404]
})

I have no idea what res should or would be, but I need to know if the document was found/exists.

Edit: Got it working with require('thunkify-wrap').genify(client.get). Now both yield client.get({...}) AND yield *client.get({...}) works. Beats me.

Gnimmelf
  • 137
  • 2
  • 9

1 Answers1

0

I think the easiest way could be wrapping around the Elasticsearch client with thunkify. This might do it:

var thunkify = require('thunkify');
var get = thunkify(client.get);

var res = yield get({ ... });
realguess
  • 1,133
  • 2
  • 10
  • 10
  • I think I tried that and got `illegal invocation` error. Maybe have to do `get.bind(client)`... Will test this. – Gnimmelf Jul 25 '14 at 09:43