Pomelo
Search and Print Program
Pomelo is a search and print program written in Javascript. It takes in a keyword as input, searches for it in the JSON data and prints out the result as an HTML table.
Project Overview
The Pomelo program has two functionalities, 1. The Search Functionality and 2. The Print Functionality. JavaScript is used to make both of these functionalites work. For the print functionality HTML and CSS are also involved.
The Search Functionality
Pomelo comes with various query methods, which can be used to query JSON data. Some of the methods are find, where, orWhere, whereIn, whereContains and so on. Data can also be aggregated after querying using methods like sum, count, groupBy, max, min. Here's an example.
- // An example of how Pomelo can be used.
- const Q = new Pomelo(JsonObject);
- const productCategory = Q.from('products')
- .where('category', '=', 2)
- .fetch();
- // This will return an array of objects with 'category 2' value.
The Print Functionality
The array returned by any of the methods of Pomelo can be passed as an argument to the printTable function. This function takes in the array and print out the data as an HTML table. This function also takes in theme names as a parameter. So the table printed out is highly customizable.
- // The printTable function takes JSON data and a theme name as parameters.
- printTable(productCategory, moon-light);
- // This function prints out an HTML table which contains the search result.
Pomelo integrated with the frontend of a product search page.