ngx-airtable
An Angular module wrapping the Airtable API
Installation
Install via npm:
npm install ngx-airtable --save
or install via yarn
yarn add ngx-airtable
Usage
NgxAirtableModule
Import ;;
Global configuration
If you want to have a global configuration you can provide an option config when importing the module:
NgxAirtableModule.forRoot
The API key is the only configuration value which has to be provided (either globally or by usage (using configure()
)).
The endpoint url and the api version are provided with the following default values:
endpointUrl: 'https://api.airtable.com'
apiVersion: 0
If you want to you can overwrite them (either globally or by usage (using configure()
).
API
This module is providing the same functionality as the official Airtable JavaScript Library airtable.js as of v0.5.0.
Airtable (Service)
Methods
configure(opts: AirtableConfiguration): Airtable
: provides the configuration or overrides the global configuration used to connect to the Airtable APIbase(baseId: string): Base
: creates a new Base instance identified by id
Properties
options: AirtableConfiguration
: provides an accessor for the options object passed to the configure method
Base
Methods
table(tableOpts: {tableName?: string; tableId?: string;}): Table
: creates a new Table instance identified by name or id
Properties
baseId: string
: provides an accessor for the Base's idairtable: Airtable
: provides an accessor for the overlaying Airtable instance
Table
Methods
find(id: string): Observable<any>
: fetches a record identified by idselect(params?: SelectParams): Query
: creates a new Query instance with the given parameterscreate(entityData: any): Observable<any>
: creates a new entityupdate(id: string, entityData: any): Observable<any>
: updated an entity identified by id with the given datadestroy(id: string): Observable<any>
: deletes an entity identified by idreplace(id: string, entityData: any): Observable<any>
: replaces an entity identified by id with the given data
Properties
base: Base
: provides an accessor for the overlaying Base instanceurlEncodedNameOrId: string
: provides an accessor for the url-friendly encoded Table name or id
Query
Methods
firstPage(): Observable<any>
: fetches the first page (ifpageSize
is omitted => max. 100 records)eachPage(): Observable<any>
: fetches each page (all records but each page is emitted separately)all(): Observable<any>
: fetches all pages and emits all records at once
AirtableConfiguration
apiKey?: string
: provides the API key to access AirtableendpointUrl?: string
: the API endpoint to hit. You might want to override it if you are using an API proxy (e.g. runscope.net) to debug your API callsapiVersion?: number
: the API version
LinkedTable
Extends Table
The LinkedTable
does the same - according to data fetching - as the Table
but it can handle entity relations while fetching.
Take a look at the DEMO.
What the LinkedTable
is not capable of are entity modifications - create, update, delete.
Methods
static fromTable(origin: Table, links: Link[]): LinkedTable
: creates a new LinkedTable instance using the provided origin Table and the given linksfind(id: string): Observable<any>
: fetches a record identified by id with its related entitiesselect(params?: SelectParams): LinkedQuery
: creates a new LinkedQuery instance with the given parameters
LinkedQuery
Extends Query
The LinkedQuery
does the same - according to data fetching - as the Query
but it can handle entity relations while fetching.
Take a look at the DEMO.
Methods
firstPage(): Observable<any>
: fetches the first page (ifpageSize
is omitted => max. 100 records) with its related entitieseachPage(): Observable<any>
: fetches each page (all records but each page is emitted separately) with its related entitiesall(): Observable<any>
: fetches all pages and emits all records at once with its related entities
SelectParams
fields?: string[]
: limits the fetched fields per recordfilterByFormula?: string
: a formula used to filter the recordsmaxRecords?: number
: limits the maximum record countpageSize?: number
: The number of records returned in each request. Must be less than or equal to 100. Default is 100.sort?: SortParam[]
: specifying sorting rules by field and directionview?: string
: the name or id of the view to fetch
SortParam
field: string
: the name of the field to sortdirection: SortDirection
: the direction to sort
SortDirection
type SortDirection = 'asc' | 'desc'