Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Airrecord.base to the ad-hoc API #41

Open
chrisfrank opened this issue Nov 13, 2018 · 3 comments
Open

Add Airrecord.base to the ad-hoc API #41

chrisfrank opened this issue Nov 13, 2018 · 3 comments
Labels

Comments

@chrisfrank
Copy link
Collaborator

Airtable's node client lets you quickly instantiate a base and interact with its tables. We can do likewise.

Node reference:

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

base('pages').find('recRECID', function(err, record) {
    if (err) { console.error(err); return; }
    console.log(record);
});

Proposed ruby style:

@base = Airrecord::Base.new("YOUR_API_KEY", "appYOUR_APP_ID")
@base.table("pages") #=> <Anonymous Airrecord::Table>
@base.table("pages").records(view: "Grid view") #=> [<Page>, <Page>]
@sirupsen
Copy link
Owner

The ad-hoc API already lets you do this:

Tea = Airrecord.table("api_key", "app_key", "Teas")

Should we change it, you think?

@chrisfrank
Copy link
Collaborator Author

No, you're right. It should follow the existing format, which more closely mimics the node syntax anyway.

@base = Airrecord.base("api_key", "app_key") #=> <Airrecord::Base>
@base.table("Tea") #=> <Anonymous Airrecord::Table @api_key="api_key" @app_key="app_key">
Coffee = Airrecord.table("api_key", "some_other_app_key", "Coffee")

Airrecord.base would make it a bit more convenient to instantiate many tables from the same base with the same credentials. And Airrecord.table should remain available as a convenient way of accessing tables from different bases, etc.

@sirupsen
Copy link
Owner

Sounds good to me. This wouldn't be a breaking change, so we can do this in 1.1.

@sirupsen sirupsen added the 1.1 label Nov 14, 2018
@chrisfrank chrisfrank changed the title Add Airrecord::Base to the ad-hoc API Add Airrecord.base to the ad-hoc API Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants