@dashpilot/s3-json-db

中文文档
1.1.0发布于 2023/08/02CommonJS近 30 天下载 3506

Use S3 as a simple json database and serverless API

原始使用文档
文档目录5 节
  1. About
  2. Installation
  3. Usage
  4. Configuration
  5. Press the :star: button

s3-json-db

Use Amazon S3 as a simple JSON database and serverless API

About

S3 JSON DB is a simple file-based JSON database for Amazon S3. It allows you to insert, update, retrieve and delete entries. All entries are stored on S3 as objects in a single json file, so you can also easily retrieve them from a Single Page Application or any server-side rendered app (without needing this module). You can use it to quickly prototype a serverless app or backend for your SPA. Compatible with Amazon S3, Digitalocean Spaces, Linode Object Storage, BackBlaze B2, etc. https://www.npmjs.com/package/@dashpilot/s3-json-db

Installation

npm install @dashpilot/s3-json-db

Usage

const S3DB = require('s3-json-db');
const db = new S3DB(s3_key, s3_secret, s3_bucket, s3_prefix, s3_acl, s3_endpoint);
const table = 'entries';

let data = {
  title: 'This is the first entry',
  body: 'Lorem ipsum dolor site amet'
}

// insert
db.insert(table, data).then(id => {
  console.log("created " + id);
});

// update
db.update(table, data, id).then(id => {
  console.log("updated " + id);
});

// delete
db.delete(table, id).then(id => {
  console.log("deleted " + id);
});

// get one entry by id
db.get(table, id).then(data => {
  console.log(data);
});

// get all entries
db.get_all(table).then(data => {
  console.log(data);
});

Configuration

s3_key (required): your S3 API key
s3_secret (required): your S3 API secret
s3_bucket (required): your S3 bucket
s3_prefix (optional): optional file prefix or subfolder (for the latter end with a slash). default "";
s3_acl (optional): ACL (https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl). Default: "private", set to "public-read" if you want your data to be public (to use with a client-side app).
s3_endpoint (optional): change the endpoint if you use Digitalocean Spaces, Linode Object Storage, Backblaze B2, etc. Default: false.

To retrieve all entries client-side (set s3_acl to "public-read"):

{your_s3_url}/{bucket}/{s3_prefix}/{table}.json

Press the :star: button

Don't forget to press the :star: button to let me know I should continue improving this project.

版本与发布记录

@dashpilot/s3-json-db 共发布 10 个版本,首次发布于 2020/02/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2023/08/023 年前
1.0.92021/12/084 年前
1.0.72021/01/115 年前
1.0.62021/01/115 年前
1.0.52020/02/026 年前
1.0.42020/02/026 年前

关于 @dashpilot/s3-json-db 的常见问题

@dashpilot/s3-json-db 是什么?

Use S3 as a simple json database and serverless API

如何安装 @dashpilot/s3-json-db?

在项目目录运行 npm install @dashpilot/s3-json-db,或使用 pnpm add / yarn add / bun add。

@dashpilot/s3-json-db 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dashpilot__s3-json-db 是否存在。

@dashpilot/s3-json-db 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dashpilot/s3-json-db 可以商用吗?

@dashpilot/s3-json-db 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@dashpilot/s3-json-db 的下载量有多少?

根据 npm 官方下载统计,@dashpilot/s3-json-db 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,506 次,日均约 117 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dashpilot/s3-json-db 还在维护吗?

最新版本 1.1.0 发布于 2023/08/02(3 年前);至今共发布 10 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/02/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。