Code Monkey home page Code Monkey logo

airtable-filter's Introduction

airtable-query

A programmatic interface for creating Airtable filter functions.

##Installation

$ npm install --save airtable-filter

##Usage

//create an instance of Airtable
var Airtable = require('airtable')
Airtable.configure({
    endpointUrl: 'https://api.airtable.com',
    apiKey: 'YOUR_API_KEY'
})

//create a reference to your desired Table
var Pokemon = Airtable.base('appx65wZlf4173yqx').table('Pokemon')

//create a Filter  with the given table
var pokemon = new Filter(table('Pokemon'))

//add operations to a specific field
pokemon.field('name').isEqualTo(name)

//retreive all the records matching a query
pokemon.all().then(function(records) {
	//do some stuff
})

//retreive just the first page of records
pokemon.firstPage().then(function (records) {
	//do some stuff
})

//iterate over each record in a result
pokemon.each(function (record) {
	//called for each record in the result
}).then(function () {
	//called after all records have been iterated
})

//query for built in values like RECORD_ID()
var recordIds = ['rec26TzCrvUuZvKLC', 'recZjsPlLtKAwgK4I', 'reczBVQyj0iGlPNO5']
pokemon.id.containedIn(recordIds)
pokemon.all().then(function (records) {
	//all the pokemon where RECORD_ID() is in the array of recordIds
})

//or CREATED_TIME()
var now = Date.now()
pokemon.createdTime.lessThanOrEqualTo(now)
pokemon.all().then(function (records) {
	//all the pokemon where CREATED_AT() is before now
})

//use additional search parameters
var params = {
	pageSize: 3,
	view: 'My Lineup',
	sort: [{
		field: 'level',
		direction: 'desc'
	}],
	filterByFormula: undefined //this will be overwritten
}
pokemon.firstPage(params).then(function (records) {
	//the first 3 records in the My Lineup sorted from highest level to lowest level
})

airtable-filter's People

Contributors

jgaull avatar

Stargazers

 avatar  avatar Kevin Granger avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

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.