index.js
function search() {

    let tableName = arguments[0];
    var fname = '';
    var field;
    var keyword;
    var callback;

    if (arguments.length === 4) {
        fname = path.join(userData, tableName + '.json');
        field = arguments[1];
        keyword = arguments[2];
        callback = arguments[3];
    } else if (arguments.length === 5) {
        fname = path.join(arguments[1], arguments[0] + '.json');
        field = arguments[2];
        keyword = arguments[3];
        callback = arguments[4];
    }

    let exists = fs.existsSync(fname);

    if (exists) {
        let table = JSON.parse(fs.readFileSync(fname));
        let rows = table[tableName];

        if (rows.length > 0) {

            // Declare an empty list
            let foundRows = [];

            for (var i = 0; i < rows.length; i++) {
                // Check if key exists
                if (rows[i].hasOwnProperty(field)) {
                    // Make sure that an object is converted to string before
                    // applying toLowerCase()
                    let value = rows[i][field].toString().toLowerCase();
                    let n = value.search(keyword.toString().toLowerCase());

                    if (n !== -1) {
                        // The substring is found, add object to the list.
                        foundRows.push(rows[i]);
                    }

                } else {
                    callback(false, 2);
                    return;
                }
            }

            callback(true, foundRows);
            return;

        } else {
            callback(false, []);
            return;
        }
    } else {
        callback(false, 'Table file does not exist!');
        return;
    }
}
function search() {

    let tableName = arguments[0];
    var fname = '';
    var field;
    var keyword;
    var callback;

    if (arguments.length === 4) {
        fname = path.join(userData, tableName + '.json');
        field = arguments[1];
        keyword = arguments[2];
        callback = arguments[3];
    } else if (arguments.length === 5) {
        fname = path.join(arguments[1], arguments[0] + '.json');
        field = arguments[2];
        keyword = arguments[3];
        callback = arguments[4];
    }

    let exists = fs.existsSync(fname);

    if (exists) {
        let table = JSON.parse(fs.readFileSync(fname));
        let rows = table[tableName];

        if (rows.length > 0) {

            // Declare an empty list
            let foundRows = [];

            for (var i = 0; i < rows.length; i++) {
                // Check if key exists
                if (rows[i].hasOwnProperty(field)) {
                    // Make sure that an object is converted to string before
                    // applying toLowerCase()
                    let value = rows[i][field].toString().toLowerCase();
                    let n = value.search(keyword.toString().toLowerCase());

                    if (n !== -1) {
                        // The substring is found, add object to the list.
                        foundRows.push(rows[i]);
                    }

                } else {
                    callback(false, 2);
                    return;
                }
            }

            callback(true, foundRows);
            return;

        } else {
            callback(false, []);
            return;
        }
    } else {
        callback(false, 'Table file does not exist!');
        return;
    }
}
Searching function
@param {string} arguments[0] Name of the table to search for
@param {string} arguments[1] [Location of the database file] (Optional)
@param {string} arguments[2] Name of the column/key to match
@param {object} arguments[3] The part of the value of the key that is being lookup
@param {function} arguments[4] Callback function
 function search(tableName, field, keyword, callback) {