GithubHelp home page GithubHelp logo

benoror / ember-airtable Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 4.0 38 KB

Boilerplate for quickly prototyping apps with Airtable, Node & Ember

Home Page: https://medium.com/@benoror/creating-an-ember-addon-for-airtable-api-d9e38d7bef97#.33q0r7hhm

License: MIT License

JavaScript 81.79% HTML 17.11% CSS 1.10%
ember-addon ember-airtable serializer adapter ember ember-data airtable

ember-airtable's Introduction

ember-airtable

Blog post: https://medium.com/@benoror/creating-an-ember-addon-for-airtable-api-d9e38d7bef97#.33q0r7hhm

Node Proxy (Optional): https://github.com/benoror/airtable-api-proxy

NPM

Download count all time Ember Observer Score Build Status PRs Welcome

Ember addon for Airtable APIs

Dummy app: https://github.com/benoror/ember-airtable/tree/master/tests/dummy/app

*Originally based on: https://github.com/benoror/fieldbook-app

Usage

Install

ember install ember-airtable

Adapter

Use AirtableAdapter as you application's main adapter:

adapters/application.js:
import AirtableAdapter from "ember-airtable/adapter";

export default AirtableAdapter.extend({

  // API Version + Base ID
  namespace: 'v0/app_YOUR_AIRTABLE_BASE_KEY',

  headers: {
    'Accept': 'application/json',
    // API Token
    'Authorization': `Bearer key_YOUR_AIRTABLE_API_KEY`
  }
});

Serializer

Use AirtableSerializer as you application's main serializer:

serializers/application.js:
import AirtableSerializer from "ember-airtable/serializer";

export default AirtableSerializer.extend();

Models

If you want to skip persistance of certain attributes (ex. formula columns) add the readOnly option:

models/product.js:
import DS from 'ember-data';

export default DS.Model.extend({
  formula: DS.attr('string', { readOnly: true })
});

Querying Airtable API

You can use all of the API features when querying Airtable:

routes/products.js:
import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.store.query('product', {
      // Only data for fields whose names are in this list will be included in the records.
      fields: ['name', 'description'],
      // A formula used to filter records.
      filterByFormula: "NOT({name} = 'MacBook')",
      // The maximum total number of records that will be returned.
      maxRecords: 50,
      // The number of records returned in each request.
      pageSize: 10,
      // A list of sort objects that specifies how the records will be ordered.
      sort: [{field: "name", direction: "desc"}],
      // The name or ID of a view in the table. 
      view: 'active_products'
    });
  }
});

Development

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

ember-airtable's People

Contributors

benoror avatar ember-tomster avatar laantorchaweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-airtable's Issues

Table query always pluralized & fields not saving

Hi! I've having some trouble with this addon. (I'm also fairly new to Ember, so I might be doing something wrong here.)

  1. The query to the airtable always pluralizes the name. The table I wanted to access was just named portfolio, but the request always went as portfolios. (Model name in Ember was also singular) I had to change the table name to match for it to work, but it would be nice to allow the table name to be singular.

screenshot at feb 16 18-38-41

screenshot at feb 16 18-35-07

  1. Once I finally got data, Ember was only saving the id and none of the fields.

Model:
export default DS.Model.extend({ title: DS.attr('string'), description: DS.attr('string'), attachments: DS.attr('[]'), });

Route:
model() { return this.store.query('portfolio', {}); }

I tried specifying the fields and without, but the title, description, or attachments never seem to save. I tried console logging in the serializer and everything looks fine except for where it returns -- for some reason the field values aren't in the attributes with the model object type and id. ๐Ÿ˜ฌ

I'm not sure what I might be doing wrong, so help would be appreciated!! ๐Ÿ™ Thank you!

Paginated results

Hi there,
I ran into an issue using this addon. The table I am pulling data from is more than 100 entries long, Airtable's default value to paginate at, so I'm unable to get all of the data in the table.

Does ember-airtable include any way to deal with pagination?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.