Hello,
I’m able to successfully make post requests to my Airtable base via the api using a netlify function. My POST request body contains four values (we can call them w, x, y, z). What my function currently does is create a new record and adds each value to their respective field.
What I’d like to do, before creating a new record, is to first check if any records in my base have all 4 identical values for each field provided in the post request. If a record does, I’ll return a success response, if not I’ll create a new record with the POST values. I see that the select() function may be a good start but am having trouble understanding how to check if a record matches each value in a post request. For reference I’m using node.js to send this request here’s my create function that is working correctly:
let fields = JSON.parse(event.body)
const { w, x, y, z} = fields
// This is where I'd like to check if my table already has a record
// with each value in the post request as a field
await table
.create({
w,
x,
y,
z,
})
.then((records) => {
console.log("Successfully inserted into airtable")
})
.catch((err) => {
throw err
})
return {
statusCode: 202,
body: JSON.stringify({ message: "Authentic" })
Is there an easy way to do this?
Thanks for the help!