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

sheetbase

v0.1.0

Published

Use `Google sheets` such like `mongodb` to help develop website and CMS quickly.

Downloads

57

Readme

Sheetbase

Use Google sheets such like mongodb to help develop website and CMS quickly.

Example

const sheetbase = new Sheetbase({
    credentialsFile: path.join(__dirname, 'config/credentials.json'),
    credentials: '____CREDENTIALS____',
    tokenFile: path.join(__dirname, 'config/token.json'),
    token: '____TOKEN____',
    spreadsheetId: '1goRN3hwHgwevJzQ-xxxxx-xxxxxxxxxxx'
})

const insertedRow = await sheetbase.sheet().create({
  id: '12',
  name: 'Michael',
  sexy: 'M',
  age: '18'
})

const findRows = await sheetbase.sheet().find(
  {age: {$lte: 10}},
  {sort: {age: -1, name: 1}}
)

API

  • Sheetbase
    • sheet Switch sheet to control base
    • info Switch sheet to control base
  • Sheet
    • create Create row with JSON data
    • update Update rows with JSON data and matched the query
    • delete Delete rows that matched the query
    • findOne Get one row data that matched the query
    • flush Flush full sheet with new JSON data
  • Spreadsheet
    • load Load full data
    • getSheet Get a sheet
    • addSheet Add new sheet
    • deleteSheet Delete a sheet
    • append Append row
    • update Update with rows no
    • delete Delete rows or columns
    • list List sheet data
    • expand Expand sheet grids
  • Drive
    • getFile Get file info
    • exportFile Export file to format
    • exportHtml Export file to HTML
    • exportText Export file to Text
    • exportPdf Export file to Pdf

Sheetbase

Sheetbase.sheet

Sheetbase.sheet(id)
  • id
    • null is default sheet with gid 0
    • small number like 0-10 is for sheet index
    • big number is for gid
    • string is for name
const sheet = sheetbase.sheet()

Sheet

Sheet.find

Find rows in the sheet

Sheet.find(query)
  • query Mongo like query object, support
    • extract string: Case-sentisive. example {field: "string"}
    • pattern: Use regex to match. example {field: /regexp/} or {field: "*wildcard*"}
    • $empty: Check if empty cell. example {field: {$empty: true}}
    • $gt: Check cell number great than a number. {field: {$gt: 10}}}}
    • $gte: Check cell number great than or equal a number. {field: {$gte: 10}}}}
    • $lt: Check cell number less than a number. {field: {$lt: 10}}}}
    • $lte: Check cell number less than or equal a number. {field: {$lte: 10}}
    • $contains: Check cell contains a string. {field: {$contains: "string"}}
  • options
    • limit
    • skip
    • sort: {sort: {age: -1}}
// Get items that match: age great than "10", sexy is "male", have "license"
const result = await sheet.find({
  age: {$gte: 10},
  sexy: "male",
  license: {$empty: false}
})

Sheet.findOne

Find one row in the sheet

Sheet.findOne(query, options)
  • query Mongo like query object, such like "sheet.find"
  • options
// Get items that match: age great than "10", sexy is "male", have "license"
const result = await sheet.find({
  age: {$gte: 10},
  sexy: "male",
  license: {$empty: false}
})

Sheet.create

Append rows into the sheet

Sheet.create(data)
  • data Array for batch or object for one
sheet.create({
  age: 18,
  sexy: "male",
  license: "MIT"
})

Sheet.update

Update the cells in the row

Sheet.create(query, update)
  • query Mongodb like query, such as "find"
  • update Mongodb like update query
    • $inc Incre the number (string will be incresed with 0). example { age: {$inc: 1} }
    • $append Append the string to the cell
    • $prepend Prepend the string to the cell
    • $lowercase Lowercase the cell string
    • $uppercase Uppercase the cell string
    • $replace Replace the cell string. example { time: {$replace: {"am": "pm"}}}
sheet.update({
  age: 18,
  sexy: "male",
  license: "MIT"
}, {
  age: {$inc: 1},
  comment: {$append: " checked"}
})

Sheet.delete

Delete the row

Sheet.delete(query)
  • query Mongodb like query, such as "find"
sheet.delete({
  age: { $gt: 35 }
})

License

MIT