refactor: replace client deletion with user detachment and update client schema to support optional user association
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
CreateClientByUserParams,
|
||||
PaginateClientsParams,
|
||||
PaginateClientsResults,
|
||||
DetachClientUserParams,
|
||||
} from "./Clients.Interface";
|
||||
import { Document, FilterQuery, Model, Schema, model } from "mongoose";
|
||||
|
||||
@@ -96,4 +97,8 @@ export class ClientsAdapterMongoose implements IClientsAdapter {
|
||||
pages: Math.ceil(count / filters.limit),
|
||||
};
|
||||
}
|
||||
|
||||
public async detachUser(data: DetachClientUserParams): Promise<void> {
|
||||
await this.clientList.updateOne({ _id: data.clientId }, { $unset: { userId: "" } }).exec();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user