I’m working with the Node.js Airtable library and running into a weird issue. My code searches for existing records using filterByFormula but the results are inconsistent. Sometimes it finds the record that should be there, other times it returns nothing even when I know the record exists.
Here’s my search function:
findBookingByReference: async (refNumber) => {
let bookings = await tableBase('Bookings').select({
view: 'All Records',
filterByFormula: `{Reference Number} = "${refNumber}"`,
maxRecords: 1,
}).all();
return (bookings.length > 0) ? bookings[0] : null;
}
I use it like this:
let existingBooking = await findBookingByReference(booking.reference);
if (!existingBooking) {
addNewBooking(booking);
} else {
modifyBooking(booking);
}
The problem is that when the search fails to find an existing record, my code creates a duplicate instead of updating the original. This happens randomly and I can’t figure out why. Has anyone experienced similar issues with Airtable’s API reliability?