Skip to content

Commit

Permalink
feat(search-service): add create function in search query repository
Browse files Browse the repository at this point in the history
add create function in search query repository

GH-1350
  • Loading branch information
Surbhi-sharma1 committed Jan 18, 2024
1 parent 02b33bc commit 183386d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {Getter, inject} from '@loopback/core';
import {AnyObject, Count, juggler, Where} from '@loopback/repository';
import {
AnyObject,
Count,
DataObject,
Options,
Where,
juggler,
} from '@loopback/repository';
import {
DefaultUserModifyCrudRepository,
IAuthUserWithPermissions,
Expand Down Expand Up @@ -33,4 +40,13 @@ export class SearchQueryRepository extends DefaultUserModifyCrudRepository<
deleteAll(where?: Where<SearchQuery>, options?: AnyObject): Promise<Count> {
return super.deleteAllHard(where, options);
}
create(
entity: DataObject<SearchQuery>,
options?: Options | undefined,
): Promise<SearchQuery> {
if (entity.where) {
delete entity.where;
}
return super.create(entity, options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {Getter, inject} from '@loopback/core';
import {AnyObject, Count, Where} from '@loopback/repository';
import {AnyObject, Count, Options, Where} from '@loopback/repository';
import {SequelizeDataSource} from '@loopback/sequelize';
import {IAuthUserWithPermissions} from '@sourceloop/core';
import {SequelizeUserModifyCrudRepository} from '@sourceloop/core/sequelize';
import {AuthenticationBindings} from 'loopback4-authentication';
import {SearchServiceConfig} from '../..';
import {SearchServiceBindings} from '../../keys';
import {SearchQuery} from '../../models';
import {DataObject} from '@loopback/repository/src/common-types';

export class SearchQueryRepository extends SequelizeUserModifyCrudRepository<
SearchQuery,
Expand All @@ -32,4 +33,13 @@ export class SearchQueryRepository extends SequelizeUserModifyCrudRepository<
deleteAll(where?: Where<SearchQuery>, options?: AnyObject): Promise<Count> {
return super.deleteAllHard(where, options);
}
create(
entity: DataObject<SearchQuery>,
options?: Options | undefined,
): Promise<SearchQuery> {
if (entity.where) {
delete entity.where;
}
return super.create(entity, options);
}
}

0 comments on commit 183386d

Please sign in to comment.