1
0
forked from Yara724/api

Initial commit after migration to gitea

This commit is contained in:
2026-01-18 11:27:43 +03:30
parent a21039410c
commit ea4b8eb543
196 changed files with 45567 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
import { Injectable } from "@nestjs/common";
import { InjectModel } from "@nestjs/mongoose";
import { FilterQuery, Model, Types } from "mongoose";
import { BranchModel, BranchDocument } from "../schema/branch.schema";
@Injectable()
export class BranchDbService {
constructor(
@InjectModel(BranchModel.name)
private readonly branchModel: Model<BranchModel>,
) {}
async create(branch: BranchModel): Promise<BranchModel> {
return await this.branchModel.create(branch);
}
async find(branch: FilterQuery<BranchModel>): Promise<BranchDocument> {
return await this.branchModel.findOne(branch);
}
async findOne(branch: FilterQuery<BranchModel>) {
return this.branchModel.findOne(branch);
}
async findAll(insuranceId: string): Promise<BranchModel[]> {
return await this.branchModel.find({
clientKey: new Types.ObjectId(insuranceId),
});
}
async findById(id: string): Promise<BranchModel | null> {
return this.branchModel.findById(id).lean();
}
}

View File

@@ -0,0 +1,28 @@
import { Injectable } from "@nestjs/common";
import { InjectModel } from "@nestjs/mongoose";
import { FilterQuery, Model } from "mongoose";
import { ClientModel, ClientDocument } from "../schema/client.schema";
@Injectable()
export class ClientDbService {
constructor(
@InjectModel(ClientModel.name)
private readonly clientModel: Model<ClientModel>,
) {}
async create(client: ClientModel): Promise<ClientModel> {
return await this.clientModel.create(client);
}
async find(client: FilterQuery<ClientModel>): Promise<ClientDocument> {
return await this.clientModel.findOne(client);
}
async findOne(client: FilterQuery<ClientModel>) {
return this.clientModel.findOne(client);
}
async findAll(): Promise<ClientModel[]> {
return await this.clientModel.find();
}
}