What is the first parameter for the find function


#1

Hi,

Does anyone know what the first parameter is for the find function.

Here is my example i found from the api docs

base(‘Clothes’).find(‘recHCaksbNTrZKM2g’, function(err, record) {

Many Thanks


#2

Hey,

You mean this one : recHCaksbNTrZKM2g ?
It is the Id given to your record.

To retrieve your record, the api needs its ID. I don’t think you can retrieve a record without it yet.


#3

Ok, but how do would I get the ID of the record, i have seen that there a list records process (see below) but how do I get the I from this ?

var Airtable = require('airtable');
var base = new Airtable({ apiKey: 'YOUR_API_KEY' }).base('app1mjrfgjv0RUiFT');

base('Clothes').select({
    // Selecting the first 3 records in All Clothes :
    maxRecords: 3,
    view: "All Clothes "
}).eachPage(function page(records, fetchNextPage) {

    // This function (`page`) will get called for each page of records.

    records.forEach(function(record) {
        console.log('Retrieved ', record.get('Name'));
    });

    // To fetch the next page of records, call `fetchNextPage`.
    // If there are more records, `page` will get called again.
    // If there are no more records, `done` will get called.
    fetchNextPage();

}, function done(error) {
    if (error) {
        console.log(error);
    }
});

#4

When you get to the record inside your forEach loop, you can get it like this:
record.id
If you want to see it, try console.log(record.id) after the line records.forEach(function(record) {

Hope this will help you.


#5

Great, thank you very much, I am new to airtable.

Thank you for your attention and patience.

Many Thanks

Ethan


#6

Is there a way to see the record.id without iterating through all of my records? I have a separate data source that will be referencing a specific row from my data, so I’d love to be able to see the list of records/ids to be able to transpose them to the other system.


#7

The easiest way is a non-programmatic solution: Add a formula field to your base with the formula defined as RECORD_ID() and modify your external data source to store a copy of that field…

Otherwise, you’ll have to search for each record based on its primary field (assuming that’s a unique value) or, alas, iterate through all of your records.