const db = require('../db.js');

module.exports = (self, offSet) => {
  const queryStr = `SELECT teach.teach_id FROM (
                      (
                        SELECT users_languages_levels.user AS teach_id FROM users_languages_levels 
                         INNER JOIN languages_levels 
                           ON users_languages_levels.languages_levels = languages_levels.id
                         INNER JOIN languages
                           ON languages_levels.language = languages.id
                         INNER JOIN levels
                           ON languages_levels.level = levels.id
                         WHERE languages.name IN (${self.willLearn.map(language => language[0]).join(',')}) AND level.name IN ('fluent', 'native')
                      ) AS teach
                      INNER JOIN
                      (
                        SELECT users_languages_levels.user AS learn_id FROM users_languages_levels 
                         INNER JOIN languages_levels 
                           ON users_languages_levels.languages_levels = languages_levels.id
                         INNER JOIN languages
                           ON languages_levels.language = languages.id
                         INNER JOIN levels
                           ON languages_levels.level = levels.id
                         WHERE languages.name IN (${self.canTeach.map(language => language[0]).join(',')}) AND level.name IN ('fluent', 'native')
                      ) AS learn
                        ON teach.teach_id = learn.learn_id
                      )
                    `;
  // db.query();
};

@@ -253,32 +253,33 @@
                 
+ 
 INNER JOIN langu
@@ -283,32 +283,33 @@
 nguages_levels %0A
+ 
                 
@@ -375,33 +375,35 @@
 guages_levels.id
-%0A
+ %0A 
                 
@@ -423,33 +423,35 @@
 R JOIN languages
-%0A
+ %0A 
                 
@@ -496,32 +496,33 @@
 e = languages.id
+ 
 %0A               
@@ -523,32 +523,33 @@
                 
+ 
 INNER JOIN level
@@ -541,33 +541,35 @@
 NNER JOIN levels
-%0A
+ %0A 
                 
@@ -608,33 +608,35 @@
 evel = levels.id
-%0A
+ %0A 
                 
@@ -757,32 +757,33 @@
 uent', 'native')
+ 
 %0A               
@@ -799,16 +799,17 @@
 AS teach
+ 
 %0A       
@@ -833,16 +833,17 @@
 NER JOIN
+ 
 %0A       
@@ -850,32 +850,33 @@
                (
+ 
 %0A               
@@ -952,32 +952,33 @@
 nguages_levels %0A
+ 
                 
@@ -1034,32 +1034,33 @@
                 
+ 
 ON users_languag
@@ -1099,33 +1099,35 @@
 guages_levels.id
-%0A
+ %0A 
                 
@@ -1155,17 +1155,19 @@
 anguages
-%0A
+ %0A 
         
@@ -1224,25 +1224,27 @@
 languages.id
-%0A
+ %0A 
             
@@ -1273,17 +1273,19 @@
 N levels
-%0A
+ %0A 
         
@@ -1340,17 +1340,19 @@
 evels.id
-%0A
+ %0A 
         
@@ -1521,16 +1521,17 @@
 AS learn
+ 
 %0A       
@@ -1581,16 +1581,17 @@
 learn_id
+ 
 %0A       
@@ -1606,16 +1606,88 @@
        )
+ %0A                      LIMIT 20 %0A                      OFFSET $%7BoffSet%7D
 %0A       

Add limit and offset in query string