Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1338 #1339

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/datasets/datasets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ import { ConfigService } from "@nestjs/config";
import { REQUEST } from "@nestjs/core";
import { InjectModel } from "@nestjs/mongoose";
import { Request } from "express";
import { FilterQuery, Model, QueryOptions, UpdateQuery } from "mongoose";
import {
FilterQuery,
HydratedDocument,
IfAny,
Model,
ModifyResult,
Query,
QueryOptions,
Schema,
UpdateQuery,
} from "mongoose";
import { JWTUser } from "src/auth/interfaces/jwt-user.interface";
import { IFacets, IFilters } from "src/common/interfaces/common.interface";
import {
Expand Down Expand Up @@ -39,6 +49,7 @@ import {
} from "./dto/update-raw-dataset.dto";
import { IDatasetFields } from "./interfaces/dataset-filters.interface";
import { DatasetClass, DatasetDocument } from "./schemas/dataset.schema";
import Types = Schema.Types;

@Injectable({ scope: Scope.REQUEST })
export class DatasetsService {
Expand Down Expand Up @@ -288,7 +299,30 @@ export class DatasetsService {
}

// DELETE dataset
async findByIdAndDelete(id: string): Promise<DatasetClass | null> {
async findByIdAndDelete(id: string): Promise<
Query<
ModifyResult<HydratedDocument<DatasetDocument, object, object>>,
Document & DatasetClass & Document extends {
_id?: infer U;
}
? IfAny<
U,
DatasetClass &
Document & {
_id: Types.ObjectId;
},
DatasetClass & Document & Required<{ _id: U }>
>
: DatasetClass &
Document & {
_id: Types.ObjectId;
},
object,
DatasetClass & Document,
"findOneAndDelete"
> &
object
> {
if (this.ESClient) {
await this.ESClient.deleteDocument(id);
}
Expand Down
8 changes: 6 additions & 2 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, Logger, OnModuleInit } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { InjectModel } from "@nestjs/mongoose";
import { genSalt, hash } from "bcrypt";
import { FilterQuery, Model } from "mongoose";
import { FilterQuery, HydratedDocument, Model, ModifyResult } from "mongoose";
import { CreateUserIdentityDto } from "./dto/create-user-identity.dto";
import { CreateUserDto } from "./dto/create-user.dto";
import { RolesService } from "./roles.service";
Expand Down Expand Up @@ -249,7 +249,11 @@ export class UsersService implements OnModuleInit {
}

// NOTE: This is just for testing purposes inside accessGroups.e2e-spec.ts
async removeUserIdentity(userId: string): Promise<UserIdentity | null> {
async removeUserIdentity(
userId: string,
): Promise<
ModifyResult<HydratedDocument<UserIdentityDocument, object, object>>
> {
const removedUserIdentity = await this.userIdentityModel
.findOneAndDelete({ userId })
.exec();
Expand Down
Loading