pocketbase-tools
Version:
A TypeScript toolkit for PocketBase, featuring a standard service/action/types layered structure. It provides interfaces and implementations for common business logic such as users, products, company profiles, and file utilities, making it suitable for se
20 lines (19 loc) • 626 B
JavaScript
import { createProductsCollection } from "../product.service";
import { createProfileCollection } from "../profile.action";
/**
* 一键初始化所需表结构
* @param options 选择要初始化的表,默认全部
*/
export async function initCollections(options = {}) {
const results = {};
// 默认全部 true
const opts = { products: true, profile: true, ...options };
if (opts.products) {
results.products = await createProductsCollection();
}
if (opts.profile) {
results.profile = await createProfileCollection();
}
// 可继续扩展更多表
return results;
}