Defines service that access AirTable's data, and use DI with typedi.
import { Service, Container } from 'typedi';import { DataService, BaseModel, API_KEY_TOKEN } from '@thomascsd/stools';Container.set(API_KEY_TOKEN, process.env.<your api key>);const BASE_ID = '<your base id>';export class Contact extends BaseModel { name: string; email: string; mobile: string;}@Service()export class ContactService {constructor(private db: DataService) {}async getContacts(): Promise<Contact[]> { return await this.db.getDatas<Contact>(BASE_ID, '<your table name of AirTable>');}async saveContact(contact: Contact) { return await this.db.saveData<Contact>(BASE_ID, '<your table name of AirTable>', contact);}async updateContact(contact: Contact) { return await this.db.updateData<Contact>(BASE_ID, '<your table name of AirTable>', contact);}}
Delete data from AirTable
DataService
{Promise}
Get Datas from AirTable
{Promise<T[]>}
Insert data to Airtable
Update data to AirTable
Generated using TypeDoc
Defines service that access AirTable's data, and use DI with typedi.