1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.DefaultHasManyRepository = void 0;
|
8 | const repositories_1 = require("../../repositories");
|
9 | class DefaultHasManyRepository {
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | constructor(getTargetRepository, constraint) {
|
17 | this.getTargetRepository = getTargetRepository;
|
18 | this.constraint = constraint;
|
19 | }
|
20 | async create(targetModelData, options) {
|
21 | const targetRepository = await this.getTargetRepository();
|
22 | return targetRepository.create((0, repositories_1.constrainDataObject)(targetModelData, this.constraint), options);
|
23 | }
|
24 | async find(filter, options) {
|
25 | const targetRepository = await this.getTargetRepository();
|
26 | return targetRepository.find((0, repositories_1.constrainFilter)(filter, this.constraint), options);
|
27 | }
|
28 | async delete(where, options) {
|
29 | const targetRepository = await this.getTargetRepository();
|
30 | return targetRepository.deleteAll((0, repositories_1.constrainWhere)(where, this.constraint), options);
|
31 | }
|
32 | async patch(dataObject, where, options) {
|
33 | const targetRepository = await this.getTargetRepository();
|
34 | return targetRepository.updateAll((0, repositories_1.constrainDataObject)(dataObject, this.constraint), (0, repositories_1.constrainWhere)(where, this.constraint), options);
|
35 | }
|
36 | }
|
37 | exports.DefaultHasManyRepository = DefaultHasManyRepository;
|
38 |
|
\ | No newline at end of file |