Skip to content

FreshcodeIT/airtable-rest-graphql-postgres

Repository files navigation

Don't forget to set env variable for postgres database

DATABASE_URL=postgres://airtable@postgres/airtable npm start

or in docker-compose.yml

let airql = require('airtable-postgres-graphql');
let app = express();

const baseId = 'some base id';
const apiKey = 'some api key';

let {router, airtable} = airql.airtableRestRouter({apiKey: apiKey, base: baseId, tables: ['Property', 'Feature']});
airtable.setupPeriodicUpdate();

app.use(`/v0/${baseId}`, router); // for drop-in replacement usage with Airtable.js, just change host

airtable.onChange((event, entity) => {
    switch(event){
        case 'insert':
            return;
        case 'update':
            return;
        case 'delete':
            return;
    }
});

airtable.onChange((type, event, old, new) => {
    if (event=='update' && old['Approve status']!=new['Approve status'])
    {
        checkApproval(JSON.parse(new['Approve status']), json);
    }
})

airtable.onSelect((user, table, entity) => {
    // user select info about himself
    if (user.airtableId === entity.id)
        return entity;
    switch(table) {
        // don't return personal information, prefer Whitelist approach because field names in Airtable can be easily changed
        case 'Landlord':
            return _.pick(entity, ['Name', 'Type']);
        case 'Agent':
            return _.pick(entity, ['Name', 'MobilePhone']);
    }
});

airtable.onAssignUser((req, res) => req.local.user);

Benchmarks

Roadmap

About

Drop-in replacement for Airtable API with two-way sync backed by PostgreSQL. Graphql included.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy