@ptc-org/nestjs-query-mongoose 10.0.3 → 11.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ptc-org/nestjs-query-mongoose",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-alpha.0",
|
|
4
4
|
"description": "Mongoose adapter for @ptc-org/nestjs-query-core",
|
|
5
5
|
"homepage": "https://github.com/tripss/nestjs-query#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lodash.escaperegexp": "^4.1.2",
|
|
28
28
|
"lodash.merge": "^4.6.2",
|
|
29
29
|
"tslib": "^2.8.1",
|
|
30
|
-
"@ptc-org/nestjs-query-core": "
|
|
30
|
+
"@ptc-org/nestjs-query-core": "11.0.0-alpha.0",
|
|
31
31
|
"reflect-metadata": "0.2.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AggregateQuery, AggregateResponse, DeepPartial, DeleteManyResponse, DeleteOneOptions, Filter, FindByIdOptions, GetByIdOptions, Query, QueryOptions, QueryService, UpdateManyResponse, UpdateOneOptions } from '@ptc-org/nestjs-query-core';
|
|
1
|
+
import { AggregateQuery, AggregateResponse, CreateManyOptions, CreateOneOptions, DeepPartial, DeleteManyResponse, DeleteOneOptions, Filter, FindByIdOptions, GetByIdOptions, Query, QueryOptions, QueryService, UpdateManyResponse, UpdateOneOptions } from '@ptc-org/nestjs-query-core';
|
|
2
2
|
import { Document, Model as MongooseModel } from 'mongoose';
|
|
3
3
|
import { FilterQueryBuilder } from '../query';
|
|
4
4
|
import { ReferenceQueryService } from './reference-query.service';
|
|
@@ -77,8 +77,9 @@ export declare class MongooseQueryService<Entity extends Document> extends Refer
|
|
|
77
77
|
* const todoItem = await this.service.createOne({title: 'Todo Item', completed: false });
|
|
78
78
|
* ```
|
|
79
79
|
* @param record - The entity to create.
|
|
80
|
+
* @param opts - Additional options.
|
|
80
81
|
*/
|
|
81
|
-
createOne(record: DeepPartial<Entity>): Promise<Entity>;
|
|
82
|
+
createOne(record: DeepPartial<Entity>, opts?: CreateOneOptions<Entity>): Promise<Entity>;
|
|
82
83
|
/**
|
|
83
84
|
* Create multiple entities.
|
|
84
85
|
*
|
|
@@ -90,8 +91,9 @@ export declare class MongooseQueryService<Entity extends Document> extends Refer
|
|
|
90
91
|
* ]);
|
|
91
92
|
* ```
|
|
92
93
|
* @param records - The entities to create.
|
|
94
|
+
* @param opts - Additional options.
|
|
93
95
|
*/
|
|
94
|
-
createMany(records: DeepPartial<Entity>[]): Promise<Entity[]>;
|
|
96
|
+
createMany(records: DeepPartial<Entity>[], opts?: CreateManyOptions<Entity>): Promise<Entity[]>;
|
|
95
97
|
/**
|
|
96
98
|
* Update an entity.
|
|
97
99
|
*
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MongooseQueryService = void 0;
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
+
const nestjs_query_core_1 = require("@ptc-org/nestjs-query-core");
|
|
6
7
|
const query_1 = require("../query");
|
|
7
8
|
const reference_query_service_1 = require("./reference-query.service");
|
|
8
9
|
/**
|
|
@@ -112,8 +113,10 @@ class MongooseQueryService extends reference_query_service_1.ReferenceQueryServi
|
|
|
112
113
|
* const todoItem = await this.service.createOne({title: 'Todo Item', completed: false });
|
|
113
114
|
* ```
|
|
114
115
|
* @param record - The entity to create.
|
|
116
|
+
* @param opts - Additional options.
|
|
115
117
|
*/
|
|
116
|
-
async createOne(record) {
|
|
118
|
+
async createOne(record, opts) {
|
|
119
|
+
(0, nestjs_query_core_1.ensureMatchesCreationFilter)(record, opts?.filter);
|
|
117
120
|
this.ensureIdIsNotPresent(record);
|
|
118
121
|
return this.Model.create(record);
|
|
119
122
|
}
|
|
@@ -128,10 +131,12 @@ class MongooseQueryService extends reference_query_service_1.ReferenceQueryServi
|
|
|
128
131
|
* ]);
|
|
129
132
|
* ```
|
|
130
133
|
* @param records - The entities to create.
|
|
134
|
+
* @param opts - Additional options.
|
|
131
135
|
*/
|
|
132
|
-
async createMany(records) {
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
async createMany(records, opts) {
|
|
137
|
+
const recordsToCreate = (0, nestjs_query_core_1.filterCreatableRecords)(records, opts?.filter);
|
|
138
|
+
recordsToCreate.forEach((recordToCreate) => this.ensureIdIsNotPresent(recordToCreate));
|
|
139
|
+
return this.Model.create(recordsToCreate);
|
|
135
140
|
}
|
|
136
141
|
/**
|
|
137
142
|
* Update an entity.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoose-query.service.js","sourceRoot":"","sources":["../../../../../packages/query-mongoose/src/services/mongoose-query.service.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,2CAAkD;
|
|
1
|
+
{"version":3,"file":"mongoose-query.service.js","sourceRoot":"","sources":["../../../../../packages/query-mongoose/src/services/mongoose-query.service.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,2CAAkD;AAClD,kEAkBmC;AAGnC,oCAA+D;AAC/D,uEAAiE;AAMjE;;;;;;;;;;;;;;;GAeG;AACH,MAAa,oBACX,SAAQ,+CAA6B;IAGrC,YACW,KAA4B,EAC5B,qBAAiD,IAAI,0BAAkB,CAAC,KAAK,CAAC;QAEvF,KAAK,EAAE,CAAA;QAHE,UAAK,GAAL,KAAK,CAAuB;QAC5B,uBAAkB,GAAlB,kBAAkB,CAA4D;IAGzF,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,KAAK,CAAC,KAAoB;QACrC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,KAAK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