File size: 747 Bytes
7b850b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Injectable } from '@nestjs/common';

@Injectable()
export class sharedCrudService {
  private service;
  constructor(private serviceObj) {
    // super();
    this.service = serviceObj;
  }
  sharedCreate = (body) => {
    return this.service.create(body);
  };
  sharedUpdate = (clause, body) => {
    return this.service.updateOne(clause, body);
  };
  sharedFindOne = (clause) => {
    return this.service.findOne(clause);
  };
  sharedFindOneAndUpdate = (clause, body, options) => {
    return this.service.findOneAndUpdate(clause, body, options);
  };
  sharedFind = (clause) => {
    return this.service.find(clause);
  };
  sharedDelete = (clause) => {
    return this.service.deleteOne(clause);
  };
}