I am using Node.js library to communicate with AirTable, official js library. I am having a problem with filterByFormula. Sometimes when I try to find a record in AirTable I don’t get results even though I am pretty sure that there should be some results. My logic is such that if I do not find the record in AirTable I create a new one. If I find it I update an existing one. This logic leads to problem with same entries entered twice.
This is my query:
getReservationByID: async (externalID) { let reservations = await calendarBase('Reservations').select({ view: 'Main View', filterByFormula: `{External ID} = \\"${externalID}\\"`, maxRecords: 1, }).all(); return (reservations.length > 0) ? reservations[0] : null; },
And this function is used like this:
let oldReservation = await getReservationByID(reservation.id);
if (!oldReservation) {
createNewReservation(reservation);
} else {
updateReservation(reservation);
}
As you can see, it is essential for me to get record from AirTable if it exists, but sometimes AirTable is not returning an existing record with given ID and then I get duplicate with same external ID. Am I doing something wrong or is there some issue that I am not aware of?