This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead of using regexp like so: | |
ancestors column would be something like: {"category": 1} | |
WHERE `ancestors` REGEXP '(.*\"category\":\"1\")' | |
Use the JSON functions: | |
WHERE JSON_EXTRACT(`ancestors`, 'category') = 1 | |
Arrays: | |
WHERE JSON_SEARCH(JSON_EXTRACT('{"categories": [1,2,3]}', 'categories'), "1") != null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cities = ['rome', 'madrid', 'paris', 'brussels', 'eindhoven', 'berlin', 'copenhagen', 'stockholm']; | |
const myAwesomeSearch = value => cities.filter(city => city.indexOf(value) !== -1); | |
const input = document.querySelector('input'); | |
const suggestions = document.querySelector('#suggestions'); | |
Rx.Observable.fromEvent(input, 'keyup') | |
.pluck('target', 'value') | |
.map(value => myAwesomeSearch(value)) | |
.map(cities => cities.map(city => `<li>${city}</li>`).join('')) |