feat(server): add model base (#9734)

This commit is contained in:
forehalo
2025-01-17 02:03:53 +00:00
parent c2149f218b
commit 64335b9e0c
12 changed files with 105 additions and 65 deletions
@@ -1,8 +1,9 @@
import { Injectable, Logger } from '@nestjs/common';
import { Feature, PrismaClient } from '@prisma/client';
import { Injectable } from '@nestjs/common';
import { Feature } from '@prisma/client';
import { z } from 'zod';
import { PrismaTransaction } from '../base';
import { BaseModel } from './base';
import { Features, FeatureType } from './common';
type FeatureNames = keyof typeof Features;
@@ -17,11 +18,7 @@ type FeatureConfigs<T extends FeatureNames> = z.infer<
// We have to manually update all the users and workspaces binding to the latest version, which are thousands of handreds.
// This is a huge burden for us and we should remove it.
@Injectable()
export class FeatureModel {
private readonly logger = new Logger(FeatureModel.name);
constructor(private readonly db: PrismaClient) {}
export class FeatureModel extends BaseModel {
async get<T extends FeatureNames>(name: T) {
const feature = await this.getLatest(this.db, name);