Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

OR in search criteria #356

krasiyan opened this Issue Mar 6, 2014 · 2 comments


None yet
2 participants

krasiyan commented Mar 6, 2014

According to the documentation - "You can use the special 'OR' on two criterion to find messages matching either search criteria". Is it possible to use more than two criterion for a single property? For example how can I fetch all messages, which have a value of x-gm-thrid among (x, y, z, ....) - fetching all messages from multiple threads.

Thank you!


mscdex commented Mar 6, 2014

You could use something like this to generate the search query:

function makeCriteria(thrids) {
  var len = thrids.length;
  if (len === 0)
    return [];
  else if (len === 1)
    return [['X-GM-THRID', thrids[0]]];
  var ret = ['OR', ['X-GM-THRID', thrids[0]]], cur = ret, next;
  for (var i = 1; i < len; ++i) {
    if ((len - i) === 1)
      cur.push(['X-GM-THRID', thrids[i]]);
    else {
      next = ['OR', ['X-GM-THRID', thrids[i]]];
      cur = next;
  return [ret];

Just pass in an array of x-gm-thrids.

Awesome implementation :) Works flawlessly! Thank you! 👍

@krasiyan krasiyan closed this Mar 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment