Help

Retrieve a record by fields

Topic Labels: API
5210 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Ryo_Konishi
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi, I’ve been working on a Next.js app with Airtable.

I’m trying to retrieve a single record by specifying the field (not reocrd ID provided by Airtabe).

I refered to the document below, but it only mentions the way of doing it by the record ID.

The code below is working fine, but I’d like to get a record by the specified column (eg. where “user_id” = 987813 ).

//export const getServerSideProps = async (context) => {
export async function getServerSideProps(context) {
    let todos = await table.find('rec1PDbe0ww22feo3');
    return {
        props: {
            initialTodos:  getMinifiedRecord(todos),
        },
    };
}

Thanks,

2 Replies 2

To get a specific record based on field values you need to get records for the table with filterByFormula. You will then get an array of only the records that match that condition.

Ryo_Konishi
5 - Automation Enthusiast
5 - Automation Enthusiast

Thanks for the reply.

Now I found the way to do it with select method, do you know if they have it with find method?

let todos = await table.select({maxRecords: 1,filterByFormula: "NOT({email} = '')"}).firstPage();