@a_team/prisma

中文文档
3.31.18-win发布于 2026/11/05ISCTypeScriptCommonJS近 30 天下载 5629
  • This package contains a shared Prisma schema, organized into multiple files, to be used across multiple repositories/projects. - By centralizing the schema definitions, w
原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Playground
  4. Deployment versioning
  5. Publishing a new version

A.Team prisma library

  • This package contains a shared Prisma schema, organized into multiple files, to be used across multiple repositories/projects.
  • By centralizing the schema definitions, we ensure consistency and reduce duplication of effort:
    • Consistency: We are targeting the same MongoDB database. If we use different schema definition files, there's a risk of having inconsistent model definitions, which could lead to conflicts and data overrides.
    • Efficiency: A single schema definition can reduce redundant work. Currently, the schema file has over 300 lines, and this could easily grow to 1000+ lines as we onboard more collections. By working collaboratively on a single schema definition, we can streamline our efforts and improve the overall quality.

Installation

  • To install this package, add the following optional dependencies (where X.Y.Z represents the version):
"optionalDependencies": {
    "@a_team/prisma-win": "npm:@a_team/[email protected]",
    "@a_team/prisma-macos": "npm:@a_team/[email protected]",
    "@a_team/prisma-linux": "npm:@a_team/[email protected]",
    "@a_team/prisma-linux-debian": "npm:@a_team/[email protected]"
}
  • Add the following script as postinstall & change per need in your service:
const fs = require('fs');
const path = require('path');

const getLinuxDistribution = () => {
  try {
    const osRelease = fs.readFileSync('/etc/os-release', 'utf-8');
    const match = osRelease.match(/^ID=(.+)$/m);
    return match ? match[1].replace(/"/g, '') : 'unknown';
  } catch (error) {
    console.error('Failed to detect Linux distribution:', error.message);
    return 'unknown';
  }
};

const getPlatformPackage = () => {
  switch (process.platform) {
    case 'darwin':
      return '@a_team/prisma-macos';
    case 'win32':
      return '@a_team/prisma-win';
    default:
      const linuxDistro = getLinuxDistribution();

      if (linuxDistro === 'debian') {
        return '@a_team/prisma-linux-debian';
      }

      return '@a_team/prisma-linux';
  }
};

const platformPackage = getPlatformPackage();
const nodeModulesPath = path.join(__dirname, '..', 'node_modules');
const sourcePath = path.join(nodeModulesPath, platformPackage);
const targetPath = path.join(nodeModulesPath, '@a_team/prisma');

if (fs.existsSync(sourcePath)) {
  if (fs.existsSync(targetPath)) {
    fs.rmSync(targetPath, { recursive: true, force: true });
  }

  fs.renameSync(sourcePath, targetPath);
  console.log(`Renamed ${platformPackage} to @a_team/prisma`);
} else {
  console.error(`Platform-specific package ${platformPackage} not found`);
  process.exit(1);
}
  • The script above will link the required OS dependency as the main one.

Usage

  • To use the library:
import { ATeamPrismaClient } from '@a_team/prisma';

export class DbClient extends ATeamPrismaClient {
  constructor(connectionUrl: string) {
    super(connectionUrl);
  }

  async onModuleInit() {
    await this.connect();
  }

  async onModuleDestroy() {
    await this.disconnect();
  }
}

Playground

  • The playground is a dedicated space where you can test and experiment with the prisma client and schema.
  • It contains various scripts that demonstrate how to interact with your database models.
  • Before running any playground scripts, make sure to set up your environment variables. First, copy the .env.sample file to .env:
cp .env.sample .env
  • Then, fill in the required environment variables in the .env file.
  • To run a playground script, use the following command:
npx ts-node playground/missionSpec.ts

Deployment versioning

  • Given a version pattern MAJOR.MINOR.PATCH, incrementing and releasing should be done as:
    • MAJOR version must be increased when incompatible service/code changes are made,
    • MINOR version must be increased when functionality in a backwards-compatible manner is made,
    • PATCH version must be increased when backwards-compatible bug fixes (for existing features) are made.

Publishing a new version

  • Pull the latest changes on the main branch and push the following tag to the repository:

    git tag v<major>.<minor>.<patch> # matches v0.0.1
    git push origin tag v<major>.<minor>.<patch> # runs the publishing process
    
  • This tag creates the new package versions needed and pushes them towards the npm repository,

  • A release on the github repository is generated,

  • A slack notification is sent to the required channel with the release changes.

版本与发布记录

@a_team/prisma 共发布 875 个版本,首次发布于 2024/07/16;过去 12 个月发布了 255 个版本。

版本发布日期距今
3.31.18-winlatest2026/11/05今天
3.31.18-linux-debian2026/11/05今天
3.31.18-macos-docker-linux2026/11/05今天
3.31.18-macos2026/11/05今天
3.31.18-linux2026/11/05今天
3.31.17-macos-docker-linux2026/10/2016 天前

关于 @a_team/prisma 的常见问题

@a_team/prisma 是什么?

This package contains a shared Prisma schema, organized into multiple files, to be used across multiple repositories/projects. - By centralizing the schema definitions, w

如何安装 @a_team/prisma?

在项目目录运行 npm install @a_team/prisma,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@prisma/client(>=5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@a_team/prisma 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@a_team/prisma 支持 ESM 还是 CommonJS?

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

@a_team/prisma 可以商用吗?

@a_team/prisma 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@a_team/prisma 的下载量有多少?

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

@a_team/prisma 还在维护吗?

最新版本 3.31.18-win 发布于 2026/11/05(今天);至今共发布 875 个版本,其中过去 12 个月发布了 255 个;首次发布于 2024/07/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。