deletee method
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import {Model} from 'mongoose';
|
||||
import {Injectable} from '@nestjs/common';
|
||||
import {Injectable, NotFoundException} from '@nestjs/common';
|
||||
import {InjectModel} from '@nestjs/mongoose';
|
||||
import {Store, StoreRequest} from './store.schema';
|
||||
|
||||
@ -26,4 +26,15 @@ export class StoreService {
|
||||
async findOne(key: string): Promise<Store> {
|
||||
return this.storeModel.findOne({key});
|
||||
}
|
||||
|
||||
async removeOne(key: string): Promise<string> {
|
||||
const searchStore = await this.findOne(key);
|
||||
|
||||
if (searchStore) {
|
||||
await searchStore.remove();
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
throw new NotFoundException(`Not Found key - ${key}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user