{"_id":"566a2391434e53390069d8e3","githubsync":"","user":"56672364f672550d00085227","__v":14,"category":{"_id":"5667789f575ec10d00640b80","pages":["56677ec5be6e390d004eb465","566780b78f1eec0d00d9e391","566791b8ee1dbf0d008f611b","566794b305cae40d00bea738","5667957306039e0d00c4eba7","5668d4e1f921480d00a34555","5668d76dc3de130d004416ba","5668d8b7d000ff1700ca477a","5668d97b07625117002c2727","5668dcf02961f917006ada2c","566a1c83e233063900c10f80","566a1eaed000ff1700ca4941","566a1ec007625117002c29e9","566a2391434e53390069d8e3","566a26b455e4b32100935f47","566a2716f625510d000e55e6","566a29cbf625510d000e55e9","566a2fdf0405980d001f40af","566a30451766bf0d00e737bd","566a328bf625510d000e55f1","566a34561e08750d00a0c497","566a348d1766bf0d00e737c4","566b92b471dc6a0d00b2493c"],"version":"5667237fee53940d00516247","__v":23,"project":"5667237eee53940d00516244","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-09T00:41:03.215Z","from_sync":false,"order":1,"slug":"api-reference","title":"API Reference"},"project":"5667237eee53940d00516244","version":{"_id":"5667237fee53940d00516247","__v":4,"project":"5667237eee53940d00516244","createdAt":"2015-12-08T18:37:51.439Z","releaseDate":"2015-12-08T18:37:51.439Z","categories":["56672380ee53940d00516248","5667789f575ec10d00640b80","566779078c573e0d00023d96","56677e2bbe6e390d004eb463"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-11T01:14:57.283Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":21,"body":"The .where() can be called anywhere after the[ .from()](https://jinqjs.readme.io/docs/from) and before the [.select()](https://jinqjs.readme.io/docs/select).  The .where() function can either take a string for the condition to use or a predicate. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Multiple .where()s can be used multiple times throughout a single query!\\n\\nIntroduced in version 1.5, the .filter() is synonymous to .where(), you can use them interchangeably.\"\n}\n[/block]\nThe .where() requires at least one parameter and is used for simple condition checking. Each parameter is the condition that must be true. **Each parameter is combined as an And condition**. If any of the conditions are not true then the row will be excluded in the result set. The following operators are supported: < > <= >= != == *. The * operator is used for contains.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"If the R-Value contains spaces do not surround the value with single or double quotes.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"String Parameters\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"where(string, string, string, ...)\\nfilter(string, string, string, ...)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"where(condition: string, ...conditions: string[]): jinqJs;\",\n      \"language\": \"javascript\",\n      \"name\": \"TypeScript\"\n    }\n  ]\n}\n[/block]\n\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fp4Ly986j%2F&src=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fp4Ly986j%2Fembedded%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\\\" width=\\\"600\\\" height=\\\"400\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://jsfiddle.net/tford/p4Ly986j/\",\n  \"title\": \"jinqJs - JSFiddle\",\n  \"favicon\": \"https://jsfiddle.net/favicon.png\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Predicate Parameter\"\n}\n[/block]\nThe predicate() function will receive two arguments that is the row currently being iterated over and its index number. This allowing you to perform complex logic. The predicate() function must return true or false.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"where( Function( row, index ) ) OR filter( Function( row, index ) )\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"type PredicateCondition<T> = (row: T, index: number) => boolean;\\nwhere<T>(predicate: PredicateCondition<T>): jinqJs;\",\n      \"language\": \"javascript\",\n      \"name\": \"TypeScript\"\n    }\n  ]\n}\n[/block]\n**Complex Collection** \n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fq4ouk1q1%2F&src=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fq4ouk1q1%2Fembedded%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\\\" width=\\\"600\\\" height=\\\"400\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://jsfiddle.net/tford/q4ouk1q1/\",\n  \"title\": \"jinqJs - JSFiddle\",\n  \"favicon\": \"https://jsfiddle.net/favicon.png\"\n}\n[/block]\n**Simple Array** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var result = new jinqJs()   //Filter out even #’s on an array of numbers\\n                 .from([1,2,3,4,5,6])\\n                 .where( function(row, index){ return row % 2 == 0; })\\n                 .select();\\n\\n/* result:  [2,4,6] */\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"where-filter","type":"fn","title":"where | filter"}
The .where() can be called anywhere after the[ .from()](https://jinqjs.readme.io/docs/from) and before the [.select()](https://jinqjs.readme.io/docs/select). The .where() function can either take a string for the condition to use or a predicate. [block:callout] { "type": "info", "body": "Multiple .where()s can be used multiple times throughout a single query!\n\nIntroduced in version 1.5, the .filter() is synonymous to .where(), you can use them interchangeably." } [/block] The .where() requires at least one parameter and is used for simple condition checking. Each parameter is the condition that must be true. **Each parameter is combined as an And condition**. If any of the conditions are not true then the row will be excluded in the result set. The following operators are supported: < > <= >= != == *. The * operator is used for contains. [block:callout] { "type": "warning", "body": "If the R-Value contains spaces do not surround the value with single or double quotes." } [/block] [block:api-header] { "type": "basic", "title": "String Parameters" } [/block] [block:code] { "codes": [ { "code": "where(string, string, string, ...)\nfilter(string, string, string, ...)", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "where(condition: string, ...conditions: string[]): jinqJs;", "language": "javascript", "name": "TypeScript" } ] } [/block] [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fp4Ly986j%2F&src=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fp4Ly986j%2Fembedded%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\" width=\"600\" height=\"400\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://jsfiddle.net/tford/p4Ly986j/", "title": "jinqJs - JSFiddle", "favicon": "https://jsfiddle.net/favicon.png" } [/block] [block:api-header] { "type": "basic", "title": "Predicate Parameter" } [/block] The predicate() function will receive two arguments that is the row currently being iterated over and its index number. This allowing you to perform complex logic. The predicate() function must return true or false. [block:code] { "codes": [ { "code": "where( Function( row, index ) ) OR filter( Function( row, index ) )", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "type PredicateCondition<T> = (row: T, index: number) => boolean;\nwhere<T>(predicate: PredicateCondition<T>): jinqJs;", "language": "javascript", "name": "TypeScript" } ] } [/block] **Complex Collection** [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fq4ouk1q1%2F&src=https%3A%2F%2Fjsfiddle.net%2Ftford%2Fq4ouk1q1%2Fembedded%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\" width=\"600\" height=\"400\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://jsfiddle.net/tford/q4ouk1q1/", "title": "jinqJs - JSFiddle", "favicon": "https://jsfiddle.net/favicon.png" } [/block] **Simple Array** [block:code] { "codes": [ { "code": "var result = new jinqJs() //Filter out even #’s on an array of numbers\n .from([1,2,3,4,5,6])\n .where( function(row, index){ return row % 2 == 0; })\n .select();\n\n/* result: [2,4,6] */", "language": "javascript" } ] } [/block]