🚀
无服务器架构
使用云对象存储作为后端,无需维护数据库服务器,按用量计费
import { BucketDB, FileSystemAdapter } from '@bucket-db/core';
import type { Document } from '@bucket-db/core';
interface User extends Document {
name: string;
age: number;
email: string;
}
// 创建数据库实例
const db = new BucketDB(
new FileSystemAdapter({ basePath: './data' }),
'my-app'
);
// 获取集合
const users = db.collection<User>('users');
// 插入文档
const user = await users.insert({
name: 'Alice',
age: 25,
email: 'alice@example.com'
});
// 查询文档
const adults = await users.find({ age: { $gte: 18 } });
// 更新文档
await users.update(user.id, { age: 26 });
// 删除文档
await users.delete(user.id);vs 传统数据库
vs 其他文档数据库
# 安装
bun add @bucket-db/core
# 或使用 npm
npm install @bucket-db/core立即查看快速开始指南,5 分钟完成第一个应用。