mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: add metadata repo + seeder
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Hexastack. All rights reserved.
|
||||
* Copyright © 2025 Hexastack. All rights reserved.
|
||||
*
|
||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
Model,
|
||||
ProjectionType,
|
||||
Query,
|
||||
QueryOptions,
|
||||
SortOrder,
|
||||
UpdateQuery,
|
||||
UpdateWithAggregationPipeline,
|
||||
@@ -474,6 +475,9 @@ export abstract class BaseRepository<
|
||||
async updateOne<D extends Partial<U>>(
|
||||
criteria: string | TFilterQuery<T>,
|
||||
dto: UpdateQuery<D>,
|
||||
options: QueryOptions<D> | null = {
|
||||
new: true,
|
||||
},
|
||||
): Promise<T | null> {
|
||||
const query = this.model.findOneAndUpdate<T>(
|
||||
{
|
||||
@@ -482,9 +486,7 @@ export abstract class BaseRepository<
|
||||
{
|
||||
$set: dto,
|
||||
},
|
||||
{
|
||||
new: true,
|
||||
},
|
||||
options,
|
||||
);
|
||||
const filterCriteria = query.getFilter();
|
||||
const queryUpdates = query.getUpdate();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Hexastack. All rights reserved.
|
||||
* Copyright © 2025 Hexastack. All rights reserved.
|
||||
*
|
||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
@@ -84,6 +84,7 @@ describe('BaseService', () => {
|
||||
expect(dummyRepository.updateOne).toHaveBeenCalledWith(
|
||||
createdId,
|
||||
updatedPayload,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload(updatedPayload);
|
||||
});
|
||||
@@ -98,6 +99,7 @@ describe('BaseService', () => {
|
||||
expect(dummyRepository.updateOne).toHaveBeenCalledWith(
|
||||
updatedPayload,
|
||||
updatedCriteriaPayload,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload(updatedCriteriaPayload);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Hexastack. All rights reserved.
|
||||
* Copyright © 2025 Hexastack. All rights reserved.
|
||||
*
|
||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
@@ -9,7 +9,7 @@
|
||||
import { ConflictException } from '@nestjs/common';
|
||||
import { ClassTransformOptions } from 'class-transformer';
|
||||
import { MongoError } from 'mongodb';
|
||||
import { ProjectionType } from 'mongoose';
|
||||
import { ProjectionType, QueryOptions } from 'mongoose';
|
||||
|
||||
import { TFilterQuery } from '@/utils/types/filter.types';
|
||||
|
||||
@@ -173,8 +173,9 @@ export abstract class BaseService<
|
||||
async updateOne<D extends Partial<Omit<T, keyof BaseSchema>>>(
|
||||
criteria: string | TFilterQuery<T>,
|
||||
dto: D,
|
||||
options?: QueryOptions<D> | null,
|
||||
): Promise<T | null> {
|
||||
return await this.repository.updateOne(criteria, dto);
|
||||
return await this.repository.updateOne(criteria, dto, options);
|
||||
}
|
||||
|
||||
async updateMany<D extends Partial<Omit<T, keyof BaseSchema>>>(
|
||||
|
||||
5
api/src/utils/test/fixtures/metadata.ts
vendored
5
api/src/utils/test/fixtures/metadata.ts
vendored
@@ -8,9 +8,10 @@
|
||||
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
import { Metadata, MetadataModel } from '@/setting/schemas/metadata.schema';
|
||||
import { MetadataCreateDto } from '@/setting/dto/metadata.dto';
|
||||
import { MetadataModel } from '@/setting/schemas/metadata.schema';
|
||||
|
||||
const metadataFixtures: Metadata[] = [
|
||||
const metadataFixtures: MetadataCreateDto[] = [
|
||||
{
|
||||
name: 'app-version',
|
||||
value: '2.2.0',
|
||||
|
||||
Reference in New Issue
Block a user