I have an Airtable Database with Fieldname (“Expense”) and values. I am trying to write a JS code to query if user input available in this database. Here is what I got so far. Appreciate help in getting the RegexMatch / FilterbyFormula work. Thank you!
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'myAPIkey'}).base('myAirtablebase');
var expenseCat = base('Imported table'); //name of the table
function matchDemo(airtableField, testString) {
console.log(airtableField,testString); // output works correctly "Expense Ikea"
const records = base('Imported table').select({filterByFormula:`REGEX_MATCH({${airtableField}},"${testString}")`}).all();
return records;
console.log(records);
};
matchDemo("Expense", "ikea"); // sample call to check if use input "ikea" is available in the Database