npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@roudanio/atable-lite

v1.0.5

Published

a small repo to work with airtable

Downloads

14

Readme

#airtable-admin

导入

  1. 先在 airtable 控制台创建好要导入的 table 和 field。
  2. 在控制台获取自己的 apiKey 和对应 table 的 baseId。
  3. 使用 Table.import 导入
const fields = ['cate', 'ele', 'startdate'] // 字段名称
// 导入的数据
const records = [
  [],
  ['🔥 Weekly Top 10 Custom Wordles'],
  ['🔥 Weekly Top 10 Custom Wordles', 'girls'],
  ['🔥 Weekly Top 10 Custom Wordles', ''],
  ['🏀 NBA Teams', 'nets'],
  ['🏀 NBA Teams', 'celtics'],
  ['', 'bull', '2022-12-01'],
  ['😭 Hardest 10 Wordles in Unlimited:', 'abcd3', '2010', ''],
]

Table.import({
  apiKey, baseId, name: tableName, fields, records
}).then(() => console.log('导入成功'))

API

Table

假设 table kv 里面的数据如下:

| cate | ele | | ---- | ---- | | 🔥 Weekly Top 10 Custom Wordles | girls | | 🔥 Weekly Top 10 Custom Wordles | ukraine | | 🏀 NBA Teams | celtics | | 😭 Hardest 10 Wordles in Unlimited | ashed | | 🔥 Weekly Top 10 Custom Wordles | wordle | | 😭 Hardest 10 Wordles in Unlimited | abcde | | 🏀 NBA Teams | nets |

需要事先知道自己操作的 apiKey, baseId

import { Table } from 'airtable'

const USER_API_KEY = 'xxx'
const BASE_ID = 'baseid'

const table = new Table({ baseId: BASE_ID, apiKey: USER_API_KEY, name: 'kv' })

// 也可以全局配置 apiKey
Table.configureApiKey(USER_API_KEY)
const table = new Table({ baseId: BASE_ID})

findAll

返回表中所有的数据行

table.findAll().then((res) => console.log(res.toJSON()))
[
  {
    "cate": "🔥 Weekly Top 10 Custom Wordles",
    "ele": "girls"
  },
  {
    "cate": "🔥 Weekly Top 10 Custom Wordles",
    "ele": "ukraine"
  },
  {
    "cate": "😭 Hardest 10 Wordles in Unlimited:",
    "ele": "ashed"
  },
  {
    "cate": "🏀 NBA Teams",
    "ele": "nets"
  },
  {
    "cate": "😭 Hardest 10 Wordles in Unlimited:",
    "ele": "abcde"
  },
  {
    "cate": "🔥 Weekly Top 10 Custom Wordles",
    "ele": "wordle"
  },
  {
    "cate": "🏀 NBA Teams",
    "ele": "celtics"
  }
]

removeAll

删除表中所有的数据

table.removeAll().then(() => console.log('success'))

find

接收一个 where 条件,返回满足所有对应字段的条件的数据行。

type WhereCondition = Record<string, string | RegExp>
table.find({ cate: 'Top 10', ele: /a/}).then((res) => console.log(res.toJSON()))
[
  {
    "cate": "🔥 Weekly Top 10 Custom Wordles", // '🔥 Weekly Top 10 Custom Wordles' 满足 'Top 10' 
    "ele": "ukraine" // 'ukraine' 满足 /a/
  }
]

groupBy

根据字段名,将表中的数据分组。

table.groupBy('cate').then((groups) => console.log(groups))
{
  "🔥 Weekly Top 10 Custom Wordles": [
    {
      "cate": "🔥 Weekly Top 10 Custom Wordles",
      "ele": "girls"
    },
    {
      "cate": "🔥 Weekly Top 10 Custom Wordles",
      "ele": "ukraine"
    },
    {
      "cate": "🔥 Weekly Top 10 Custom Wordles",
      "ele": "wordle"
    }
  ],
  "😭 Hardest 10 Wordles in Unlimited:": [
    {
      "cate": "😭 Hardest 10 Wordles in Unlimited:",
      "ele": "ashed"
    },
    {
      "cate": "😭 Hardest 10 Wordles in Unlimited:",
      "ele": "abcde"
    }
  ],
  "🏀 NBA Teams": [
    {
      "cate": "🏀 NBA Teams",
      "ele": "nets"
    },
    {
      "cate": "🏀 NBA Teams",
      "ele": "celtics"
    }
  ]
}

Table.import

向表中导入数据

Table.import(opts)

// opts 的类型为
{
  apiKey: string,
  baseId: string,
  name: string, // 要导入的表名
  fields: string[], // 导入的字段名称列表 ['cate', 'ele']
  records: string[][], // 导入的数据 [['aa', '11']['bb', '22']]
}