buildPermissionsQuery: function()

in src/utilities/utils.js [30:56]


  buildPermissionsQuery: function(bq_instance, bq_dataset, bq_client_data_perms, organization_id_list, identifier, identifierType, condition, token) {
    var updateRow = 'UPDATE `' + bq_instance + '.' + bq_dataset + '.' + bq_client_data_perms + '` SET Permissions = [';

    for (var i = 0; i < organization_id_list.length - 1; i++) {
      updateRow += '"' + organization_id_list[i] + '",';
    }

    updateRow += '"' + organization_id_list[organization_id_list.length - 1] + '"] WHERE ' + identifier + ' ';

    if (condition === 'contains') {
      updateRow += 'like "%' + token + '%"';
    } else if (condition === 'equals') {
      if (identifierType === 'STRING') {
        updateRow += '= "' + token + '"';
      } else {
        updateRow += '= ' + token;
      }
    } else if (condition === 'excludes') {
      if (identifierType === 'STRING') {
        updateRow += '<> "' + token + '"';
      } else {
        updateRow += '<> ' + token;
      }
    }

    return updateRow;
  },