typeorm 0.3.15-dev.3a72e35 → 0.3.15-dev.f6a3ce7
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/README.md +1 -1
- package/browser/data-source/DataSource.js +1 -2
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/driver/mongodb/MongoDriver.js +12 -19
- package/browser/driver/mongodb/MongoDriver.js.map +1 -1
- package/browser/driver/mongodb/MongoQueryRunner.d.ts +34 -78
- package/browser/driver/mongodb/MongoQueryRunner.js +43 -74
- package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/bson.typings.d.ts +1084 -0
- package/browser/driver/mongodb/bson.typings.js +3 -0
- package/browser/driver/mongodb/bson.typings.js.map +1 -0
- package/browser/driver/mongodb/typings.d.ts +4882 -4718
- package/browser/driver/mongodb/typings.js +23 -1
- package/browser/driver/mongodb/typings.js.map +1 -1
- package/browser/entity-manager/EntityManager.d.ts +6 -6
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.d.ts +46 -92
- package/browser/entity-manager/MongoEntityManager.js +66 -133
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaColumnOptions.d.ts +1 -1
- package/browser/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/browser/find-options/FindOptionsOrder.d.ts +2 -2
- package/browser/find-options/FindOptionsOrder.js.map +1 -1
- package/browser/find-options/FindOptionsRelations.d.ts +2 -2
- package/browser/find-options/FindOptionsRelations.js.map +1 -1
- package/browser/find-options/FindOptionsSelect.d.ts +2 -2
- package/browser/find-options/FindOptionsSelect.js.map +1 -1
- package/browser/find-options/FindOptionsWhere.d.ts +2 -2
- package/browser/find-options/FindOptionsWhere.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +2 -4
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/query-builder/transformer/DocumentToEntityTransformer.js +13 -6
- package/browser/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/browser/repository/BaseEntity.d.ts +4 -4
- package/browser/repository/BaseEntity.js.map +1 -1
- package/browser/repository/EntityId.d.ts +2 -2
- package/browser/repository/EntityId.js.map +1 -1
- package/browser/repository/MongoRepository.d.ts +30 -72
- package/browser/repository/MongoRepository.js +1 -38
- package/browser/repository/MongoRepository.js.map +1 -1
- package/browser/repository/Repository.d.ts +6 -6
- package/browser/repository/Repository.js.map +1 -1
- package/browser/schema-builder/MongoSchemaBuilder.js.map +1 -1
- package/commands/InitCommand.js +3 -3
- package/commands/InitCommand.js.map +1 -1
- package/data-source/DataSource.js +7 -8
- package/data-source/DataSource.js.map +1 -1
- package/driver/mongodb/MongoDriver.js +12 -19
- package/driver/mongodb/MongoDriver.js.map +1 -1
- package/driver/mongodb/MongoQueryRunner.d.ts +34 -78
- package/driver/mongodb/MongoQueryRunner.js +43 -74
- package/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/driver/mongodb/bson.typings.d.ts +1084 -0
- package/driver/mongodb/bson.typings.js +5 -0
- package/driver/mongodb/bson.typings.js.map +1 -0
- package/driver/mongodb/typings.d.ts +4882 -4718
- package/driver/mongodb/typings.js +19 -0
- package/driver/mongodb/typings.js.map +1 -1
- package/entity-manager/EntityManager.d.ts +6 -6
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.d.ts +46 -92
- package/entity-manager/MongoEntityManager.js +66 -133
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaColumnOptions.d.ts +1 -1
- package/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/find-options/FindOptionsOrder.d.ts +2 -2
- package/find-options/FindOptionsOrder.js.map +1 -1
- package/find-options/FindOptionsRelations.d.ts +2 -2
- package/find-options/FindOptionsRelations.js.map +1 -1
- package/find-options/FindOptionsSelect.d.ts +2 -2
- package/find-options/FindOptionsSelect.js.map +1 -1
- package/find-options/FindOptionsWhere.d.ts +2 -2
- package/find-options/FindOptionsWhere.js.map +1 -1
- package/index.mjs +34 -0
- package/migration/MigrationExecutor.js +2 -4
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/transformer/DocumentToEntityTransformer.js +13 -6
- package/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/repository/BaseEntity.d.ts +4 -4
- package/repository/BaseEntity.js.map +1 -1
- package/repository/EntityId.d.ts +2 -2
- package/repository/EntityId.js.map +1 -1
- package/repository/MongoRepository.d.ts +30 -72
- package/repository/MongoRepository.js +1 -38
- package/repository/MongoRepository.js.map +1 -1
- package/repository/Repository.d.ts +6 -6
- package/repository/Repository.js.map +1 -1
- package/schema-builder/MongoSchemaBuilder.js.map +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ObjectLiteral } from "../common/ObjectLiteral";
|
|
2
2
|
import { Repository } from "./Repository";
|
|
3
3
|
import { MongoFindManyOptions } from "../find-options/mongodb/MongoFindManyOptions";
|
|
4
|
-
import { AggregationCursor, BulkWriteOpResultObject, Code, Collection, CollectionAggregationOptions, CollectionBulkWriteOptions, CollectionInsertManyOptions, CollectionInsertOneOptions, CollectionOptions, CollStats, CommandCursor, Cursor, DeleteWriteOpResultObject, FindAndModifyWriteOpResultObject, FindOneAndReplaceOption, GeoHaystackSearchOptions, GeoNearOptions, InsertOneWriteOpResult, InsertWriteOpResult, MapReduceOptions, MongoCountPreferences, MongodbIndexOptions, ObjectID, OrderedBulkOperation, ParallelCollectionScanOptions, ReadPreference, ReplaceOneOptions, UnorderedBulkOperation, UpdateWriteOpResult } from "../driver/mongodb/typings";
|
|
5
4
|
import { MongoEntityManager } from "../entity-manager/MongoEntityManager";
|
|
6
5
|
import { QueryRunner } from "../query-runner/QueryRunner";
|
|
7
6
|
import { SelectQueryBuilder } from "../query-builder/SelectQueryBuilder";
|
|
8
7
|
import { MongoFindOneOptions } from "../find-options/mongodb/MongoFindOneOptions";
|
|
9
8
|
import { FindOneOptions } from "../find-options/FindOneOptions";
|
|
9
|
+
import { CreateIndexesOptions, ObjectId, ReplaceOptions, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult, Collection, CollStats, CollStatsOptions, CommandOperationOptions, CountOptions, DeleteOptions, DeleteResult, Document, Filter, FilterOperators, FindCursor, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, ListIndexesCursor, ListIndexesOptions, OrderedBulkOperation, UnorderedBulkOperation, UpdateFilter, UpdateOptions, UpdateResult } from "../driver/mongodb/typings";
|
|
10
|
+
import { FindManyOptions } from "../find-options/FindManyOptions";
|
|
10
11
|
/**
|
|
11
12
|
* Repository used to manage mongodb documents of a single entity type.
|
|
12
13
|
*/
|
|
@@ -28,7 +29,7 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
28
29
|
/**
|
|
29
30
|
* Finds entities that match given find options or conditions.
|
|
30
31
|
*/
|
|
31
|
-
find(options?:
|
|
32
|
+
find(options?: FindManyOptions<Entity> | Partial<Entity> | FilterOperators<Entity>): Promise<Entity[]>;
|
|
32
33
|
/**
|
|
33
34
|
* Finds entities that match given find options or conditions.
|
|
34
35
|
*/
|
|
@@ -73,7 +74,7 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
73
74
|
* id: 1 // where "id" is your primary column name
|
|
74
75
|
* })
|
|
75
76
|
*/
|
|
76
|
-
findOneById(id: string |
|
|
77
|
+
findOneById(id: string | number | Date | ObjectId): Promise<Entity | null>;
|
|
77
78
|
/**
|
|
78
79
|
* Finds first entity by a given find options.
|
|
79
80
|
* If entity was not found in the database - rejects with error.
|
|
@@ -87,61 +88,59 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
87
88
|
/**
|
|
88
89
|
* Creates a cursor for a query that can be used to iterate over results from MongoDB.
|
|
89
90
|
*/
|
|
90
|
-
createCursor<T = any>(query?:
|
|
91
|
+
createCursor<T = any>(query?: Filter<Entity>): FindCursor<T>;
|
|
91
92
|
/**
|
|
92
93
|
* Creates a cursor for a query that can be used to iterate over results from MongoDB.
|
|
93
94
|
* This returns modified version of cursor that transforms each result into Entity model.
|
|
94
95
|
*/
|
|
95
|
-
createEntityCursor(query?:
|
|
96
|
+
createEntityCursor(query?: Filter<Entity>): FindCursor<Entity>;
|
|
96
97
|
/**
|
|
97
98
|
* Execute an aggregation framework pipeline against the collection.
|
|
98
99
|
*/
|
|
99
|
-
aggregate<R = any>(pipeline: ObjectLiteral[], options?:
|
|
100
|
+
aggregate<R = any>(pipeline: ObjectLiteral[], options?: AggregateOptions): AggregationCursor<Entity>;
|
|
100
101
|
/**
|
|
101
102
|
* Execute an aggregation framework pipeline against the collection.
|
|
102
103
|
* This returns modified version of cursor that transforms each result into Entity model.
|
|
103
104
|
*/
|
|
104
|
-
aggregateEntity(pipeline: ObjectLiteral[], options?:
|
|
105
|
+
aggregateEntity(pipeline: ObjectLiteral[], options?: AggregateOptions): AggregationCursor<Entity>;
|
|
105
106
|
/**
|
|
106
107
|
* Perform a bulkWrite operation without a fluent API.
|
|
107
108
|
*/
|
|
108
|
-
bulkWrite(operations:
|
|
109
|
+
bulkWrite(operations: AnyBulkWriteOperation[], options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
109
110
|
/**
|
|
110
111
|
* Count number of matching documents in the db to a query.
|
|
111
112
|
*/
|
|
112
|
-
count(query?: ObjectLiteral, options?:
|
|
113
|
+
count(query?: ObjectLiteral, options?: CountOptions): Promise<number>;
|
|
113
114
|
/**
|
|
114
115
|
* Count number of matching documents in the db to a query.
|
|
115
116
|
*/
|
|
116
|
-
countBy(query?: ObjectLiteral, options?:
|
|
117
|
+
countBy(query?: ObjectLiteral, options?: CountOptions): Promise<number>;
|
|
117
118
|
/**
|
|
118
119
|
* Creates an index on the db and collection.
|
|
119
120
|
*/
|
|
120
|
-
createCollectionIndex(fieldOrSpec: string | any, options?:
|
|
121
|
+
createCollectionIndex(fieldOrSpec: string | any, options?: CreateIndexesOptions): Promise<string>;
|
|
121
122
|
/**
|
|
122
123
|
* Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.
|
|
123
124
|
* Earlier version of MongoDB will throw a command not supported error.
|
|
124
125
|
* Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.
|
|
125
126
|
*/
|
|
126
|
-
createCollectionIndexes(indexSpecs:
|
|
127
|
+
createCollectionIndexes(indexSpecs: IndexDescription[]): Promise<string[]>;
|
|
127
128
|
/**
|
|
128
129
|
* Delete multiple documents on MongoDB.
|
|
129
130
|
*/
|
|
130
|
-
deleteMany(query: ObjectLiteral, options?:
|
|
131
|
+
deleteMany(query: ObjectLiteral, options?: DeleteOptions): Promise<DeleteResult>;
|
|
131
132
|
/**
|
|
132
133
|
* Delete a document on MongoDB.
|
|
133
134
|
*/
|
|
134
|
-
deleteOne(query: ObjectLiteral, options?:
|
|
135
|
+
deleteOne(query: ObjectLiteral, options?: DeleteOptions): Promise<DeleteResult>;
|
|
135
136
|
/**
|
|
136
137
|
* The distinct command returns returns a list of distinct values for the given key across a collection.
|
|
137
138
|
*/
|
|
138
|
-
distinct(key: string, query: ObjectLiteral, options?:
|
|
139
|
-
readPreference?: ReadPreference | string;
|
|
140
|
-
}): Promise<any>;
|
|
139
|
+
distinct(key: string, query: ObjectLiteral, options?: CommandOperationOptions): Promise<any>;
|
|
141
140
|
/**
|
|
142
141
|
* Drops an index from this collection.
|
|
143
142
|
*/
|
|
144
|
-
dropCollectionIndex(indexName: string, options?:
|
|
143
|
+
dropCollectionIndex(indexName: string, options?: CommandOperationOptions): Promise<any>;
|
|
145
144
|
/**
|
|
146
145
|
* Drops all indexes from the collection.
|
|
147
146
|
*/
|
|
@@ -149,33 +148,15 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
149
148
|
/**
|
|
150
149
|
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
|
|
151
150
|
*/
|
|
152
|
-
findOneAndDelete(query: ObjectLiteral, options?:
|
|
153
|
-
projection?: Object;
|
|
154
|
-
sort?: Object;
|
|
155
|
-
maxTimeMS?: number;
|
|
156
|
-
}): Promise<FindAndModifyWriteOpResultObject>;
|
|
151
|
+
findOneAndDelete(query: ObjectLiteral, options?: FindOneAndDeleteOptions): Promise<Document>;
|
|
157
152
|
/**
|
|
158
153
|
* Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
|
|
159
154
|
*/
|
|
160
|
-
findOneAndReplace(query: ObjectLiteral, replacement: Object, options?:
|
|
155
|
+
findOneAndReplace(query: ObjectLiteral, replacement: Object, options?: FindOneAndReplaceOptions): Promise<Document>;
|
|
161
156
|
/**
|
|
162
157
|
* Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
|
|
163
158
|
*/
|
|
164
|
-
findOneAndUpdate(query: ObjectLiteral, update: Object, options?:
|
|
165
|
-
/**
|
|
166
|
-
* Execute a geo search using a geo haystack index on a collection.
|
|
167
|
-
*/
|
|
168
|
-
geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
|
|
169
|
-
/**
|
|
170
|
-
* Execute the geoNear command to search for items in the collection.
|
|
171
|
-
*/
|
|
172
|
-
geoNear(x: number, y: number, options?: GeoNearOptions): Promise<any>;
|
|
173
|
-
/**
|
|
174
|
-
* Run a group command across a collection.
|
|
175
|
-
*/
|
|
176
|
-
group(keys: Object | Array<any> | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: {
|
|
177
|
-
readPreference?: ReadPreference | string;
|
|
178
|
-
}): Promise<any>;
|
|
159
|
+
findOneAndUpdate(query: ObjectLiteral, update: Object, options?: FindOneAndUpdateOptions): Promise<Document>;
|
|
179
160
|
/**
|
|
180
161
|
* Retrieve all the indexes on the collection.
|
|
181
162
|
*/
|
|
@@ -193,19 +174,19 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
193
174
|
/**
|
|
194
175
|
* Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.
|
|
195
176
|
*/
|
|
196
|
-
initializeOrderedBulkOp(options?:
|
|
177
|
+
initializeOrderedBulkOp(options?: BulkWriteOptions): OrderedBulkOperation;
|
|
197
178
|
/**
|
|
198
179
|
* Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
|
|
199
180
|
*/
|
|
200
|
-
initializeUnorderedBulkOp(options?:
|
|
181
|
+
initializeUnorderedBulkOp(options?: BulkWriteOptions): UnorderedBulkOperation;
|
|
201
182
|
/**
|
|
202
183
|
* Inserts an array of documents into MongoDB.
|
|
203
184
|
*/
|
|
204
|
-
insertMany(docs: ObjectLiteral[], options?:
|
|
185
|
+
insertMany(docs: ObjectLiteral[], options?: BulkWriteOptions): Promise<InsertManyResult<Document>>;
|
|
205
186
|
/**
|
|
206
187
|
* Inserts a single document into MongoDB.
|
|
207
188
|
*/
|
|
208
|
-
insertOne(doc: ObjectLiteral, options?:
|
|
189
|
+
insertOne(doc: ObjectLiteral, options?: InsertOneOptions): Promise<InsertOneResult>;
|
|
209
190
|
/**
|
|
210
191
|
* Returns if the collection is a capped collection.
|
|
211
192
|
*/
|
|
@@ -213,50 +194,27 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
|
|
|
213
194
|
/**
|
|
214
195
|
* Get the list of all indexes information for the collection.
|
|
215
196
|
*/
|
|
216
|
-
listCollectionIndexes(options?:
|
|
217
|
-
batchSize?: number;
|
|
218
|
-
readPreference?: ReadPreference | string;
|
|
219
|
-
}): CommandCursor;
|
|
220
|
-
/**
|
|
221
|
-
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
|
|
222
|
-
*/
|
|
223
|
-
mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise<any>;
|
|
224
|
-
/**
|
|
225
|
-
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
|
|
226
|
-
* There are no ordering guarantees for returned results.
|
|
227
|
-
*/
|
|
228
|
-
parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise<Cursor<Entity>[]>;
|
|
229
|
-
/**
|
|
230
|
-
* Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
|
|
231
|
-
*/
|
|
232
|
-
reIndex(): Promise<any>;
|
|
197
|
+
listCollectionIndexes(options?: ListIndexesOptions): ListIndexesCursor;
|
|
233
198
|
/**
|
|
234
199
|
* Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
|
|
235
200
|
*/
|
|
236
201
|
rename(newName: string, options?: {
|
|
237
202
|
dropTarget?: boolean;
|
|
238
|
-
}): Promise<Collection<
|
|
203
|
+
}): Promise<Collection<Document>>;
|
|
239
204
|
/**
|
|
240
205
|
* Replace a document on MongoDB.
|
|
241
206
|
*/
|
|
242
|
-
replaceOne(query: ObjectLiteral, doc: ObjectLiteral, options?:
|
|
207
|
+
replaceOne(query: ObjectLiteral, doc: ObjectLiteral, options?: ReplaceOptions): Promise<Document | UpdateResult>;
|
|
243
208
|
/**
|
|
244
209
|
* Get all the collection statistics.
|
|
245
210
|
*/
|
|
246
|
-
stats(options?:
|
|
247
|
-
scale: number;
|
|
248
|
-
}): Promise<CollStats>;
|
|
211
|
+
stats(options?: CollStatsOptions): Promise<CollStats>;
|
|
249
212
|
/**
|
|
250
213
|
* Update multiple documents on MongoDB.
|
|
251
214
|
*/
|
|
252
|
-
updateMany(query: ObjectLiteral, update:
|
|
253
|
-
upsert?: boolean;
|
|
254
|
-
w?: any;
|
|
255
|
-
wtimeout?: number;
|
|
256
|
-
j?: boolean;
|
|
257
|
-
}): Promise<UpdateWriteOpResult>;
|
|
215
|
+
updateMany(query: ObjectLiteral, update: UpdateFilter<Document>, options?: UpdateOptions): Promise<Document | UpdateResult>;
|
|
258
216
|
/**
|
|
259
217
|
* Update a single document on MongoDB.
|
|
260
218
|
*/
|
|
261
|
-
updateOne(query: ObjectLiteral, update:
|
|
219
|
+
updateOne(query: ObjectLiteral, update: UpdateFilter<Document>, options?: UpdateOptions): Promise<Document | UpdateResult>;
|
|
262
220
|
}
|
|
@@ -142,7 +142,7 @@ export class MongoRepository extends Repository {
|
|
|
142
142
|
* Count number of matching documents in the db to a query.
|
|
143
143
|
*/
|
|
144
144
|
countBy(query, options) {
|
|
145
|
-
return this.manager.countBy(this.metadata.target, query
|
|
145
|
+
return this.manager.countBy(this.metadata.target, query, options);
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Creates an index on the db and collection.
|
|
@@ -206,24 +206,6 @@ export class MongoRepository extends Repository {
|
|
|
206
206
|
findOneAndUpdate(query, update, options) {
|
|
207
207
|
return this.manager.findOneAndUpdate(this.metadata.tableName, query, update, options);
|
|
208
208
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Execute a geo search using a geo haystack index on a collection.
|
|
211
|
-
*/
|
|
212
|
-
geoHaystackSearch(x, y, options) {
|
|
213
|
-
return this.manager.geoHaystackSearch(this.metadata.tableName, x, y, options);
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Execute the geoNear command to search for items in the collection.
|
|
217
|
-
*/
|
|
218
|
-
geoNear(x, y, options) {
|
|
219
|
-
return this.manager.geoNear(this.metadata.tableName, x, y, options);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Run a group command across a collection.
|
|
223
|
-
*/
|
|
224
|
-
group(keys, condition, initial, reduce, finalize, command, options) {
|
|
225
|
-
return this.manager.group(this.metadata.tableName, keys, condition, initial, reduce, finalize, command, options);
|
|
226
|
-
}
|
|
227
209
|
/**
|
|
228
210
|
* Retrieve all the indexes on the collection.
|
|
229
211
|
*/
|
|
@@ -278,25 +260,6 @@ export class MongoRepository extends Repository {
|
|
|
278
260
|
listCollectionIndexes(options) {
|
|
279
261
|
return this.manager.listCollectionIndexes(this.metadata.tableName, options);
|
|
280
262
|
}
|
|
281
|
-
/**
|
|
282
|
-
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
|
|
283
|
-
*/
|
|
284
|
-
mapReduce(map, reduce, options) {
|
|
285
|
-
return this.manager.mapReduce(this.metadata.tableName, map, reduce, options);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
|
|
289
|
-
* There are no ordering guarantees for returned results.
|
|
290
|
-
*/
|
|
291
|
-
parallelCollectionScan(options) {
|
|
292
|
-
return this.manager.parallelCollectionScan(this.metadata.tableName, options);
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
|
|
296
|
-
*/
|
|
297
|
-
reIndex() {
|
|
298
|
-
return this.manager.reIndex(this.metadata.tableName);
|
|
299
|
-
}
|
|
300
263
|
/**
|
|
301
264
|
* Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
|
|
302
265
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/repository/MongoRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAoCzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAIpD;;GAEG;AACH,MAAM,OAAO,eAEX,SAAQ,UAAkB;IAUxB,4EAA4E;IAC5E,qBAAqB;IACrB,4EAA4E;IAE5E;;;OAGG;IACH,KAAK,CAAC,KAAa,EAAE,UAAkB;QACnC,MAAM,IAAI,YAAY,CAAC,sCAAsC,CAAC,CAAA;IAClE,CAAC;IAED;;;OAGG;IACH,kBAAkB,CACd,KAAa,EACb,WAAyB;QAEzB,MAAM,IAAI,YAAY,CAAC,4CAA4C,CAAC,CAAA;IACxE,CAAC;IAED;;OAEG;IACH,IAAI,C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QAE3B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC1B,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB,KAAK,EACL,GAAG,EACH,OAAO,CACV,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAA2B;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC;IAED;;OAEG;IACH,UAAU,CACN,KAAoB,EACpB,MAAqB,EACrB,OAAuE;QAEvE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC1B,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB,KAAK,EACL,MAAM,EACN,OAAO,CACV,CAAA;IACL,CAAC;IAED;;OAEG;IACH,SAAS,CACL,KAAoB,EACpB,MAAqB,EACrB,OAA2B;QAE3B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CACzB,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB,KAAK,EACL,MAAM,EACN,OAAO,CACV,CAAA;IACL,CAAC;CACJ","file":"MongoRepository.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { Repository } from \"./Repository\"\nimport { MongoFindManyOptions } from \"../find-options/mongodb/MongoFindManyOptions\"\nimport {\n AggregationCursor,\n BulkWriteOpResultObject,\n Code,\n Collection,\n CollectionAggregationOptions,\n CollectionBulkWriteOptions,\n CollectionInsertManyOptions,\n CollectionInsertOneOptions,\n CollectionOptions,\n CollStats,\n CommandCursor,\n Cursor,\n DeleteWriteOpResultObject,\n FindAndModifyWriteOpResultObject,\n FindOneAndReplaceOption,\n GeoHaystackSearchOptions,\n GeoNearOptions,\n InsertOneWriteOpResult,\n InsertWriteOpResult,\n MapReduceOptions,\n MongoCountPreferences,\n MongodbIndexOptions,\n ObjectID,\n OrderedBulkOperation,\n ParallelCollectionScanOptions,\n ReadPreference,\n ReplaceOneOptions,\n UnorderedBulkOperation,\n UpdateWriteOpResult,\n} from \"../driver/mongodb/typings\"\nimport { MongoEntityManager } from \"../entity-manager/MongoEntityManager\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { TypeORMError } from \"../error/TypeORMError\"\nimport { MongoFindOneOptions } from \"../find-options/mongodb/MongoFindOneOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\n\n/**\n * Repository used to manage mongodb documents of a single entity type.\n */\nexport class MongoRepository<\n Entity extends ObjectLiteral,\n> extends Repository<Entity> {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: MongoEntityManager\n\n // -------------------------------------------------------------------------\n // Overridden Methods\n // -------------------------------------------------------------------------\n\n /**\n * Raw SQL query execution is not supported by MongoDB.\n * Calling this method will return an error.\n */\n query(query: string, parameters?: any[]): Promise<any> {\n throw new TypeORMError(`Queries aren't supported by MongoDB.`)\n }\n\n /**\n * Using Query Builder with MongoDB is not supported yet.\n * Calling this method will return an error.\n */\n createQueryBuilder(\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(options?: MongoFindManyOptions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n findBy(where: any): Promise<Entity[]> {\n return this.manager.findBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(\n options?: MongoFindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCount(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy(where: any): Promise<[Entity[], number]> {\n return this.manager.findAndCountBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n findByIds(ids: any[], options?: any): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target, ids, options)\n }\n\n /**\n * Finds first entity that matches given find options.\n */\n async findOne(\n options: MongoFindOneOptions<Entity>,\n ): Promise<Entity | null> {\n return this.manager.findOne(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given WHERE conditions.\n */\n async findOneBy(where: any): Promise<Entity | null> {\n return this.manager.findOneBy(this.metadata.target, where)\n }\n\n /**\n * Finds entity that matches given id.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById(\n id:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[],\n ): Promise<Entity | null> {\n return this.manager.findOneById(this.metadata.target, id)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail(options: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail(where: any): Promise<Entity> {\n return this.manager.findOneByOrFail(this.metadata.target, where)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n */\n createCursor<T = any>(query?: ObjectLiteral): Cursor<T> {\n return this.manager.createCursor(this.metadata.target, query)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n createEntityCursor(query?: ObjectLiteral): Cursor<Entity> {\n return this.manager.createEntityCursor(this.metadata.target, query)\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n */\n aggregate<R = any>(\n pipeline: ObjectLiteral[],\n options?: CollectionAggregationOptions,\n ): AggregationCursor<R> {\n return this.manager.aggregate<R>(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n aggregateEntity(\n pipeline: ObjectLiteral[],\n options?: CollectionAggregationOptions,\n ): AggregationCursor<Entity> {\n return this.manager.aggregateEntity(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n /**\n * Perform a bulkWrite operation without a fluent API.\n */\n bulkWrite(\n operations: ObjectLiteral[],\n options?: CollectionBulkWriteOptions,\n ): Promise<BulkWriteOpResultObject> {\n return this.manager.bulkWrite(this.metadata.target, operations, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n count(\n query?: ObjectLiteral,\n options?: MongoCountPreferences,\n ): Promise<number> {\n return this.manager.count(this.metadata.target, query || {}, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n countBy(\n query?: ObjectLiteral,\n options?: MongoCountPreferences,\n ): Promise<number> {\n return this.manager.countBy(this.metadata.target, query || {}, options)\n }\n\n /**\n * Creates an index on the db and collection.\n */\n createCollectionIndex(\n fieldOrSpec: string | any,\n options?: MongodbIndexOptions,\n ): Promise<string> {\n return this.manager.createCollectionIndex(\n this.metadata.target,\n fieldOrSpec,\n options,\n )\n }\n\n /**\n * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.\n * Earlier version of MongoDB will throw a command not supported error.\n * Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.\n */\n createCollectionIndexes(indexSpecs: ObjectLiteral[]): Promise<void> {\n return this.manager.createCollectionIndexes(\n this.metadata.target,\n indexSpecs,\n )\n }\n\n /**\n * Delete multiple documents on MongoDB.\n */\n deleteMany(\n query: ObjectLiteral,\n options?: CollectionOptions,\n ): Promise<DeleteWriteOpResultObject> {\n return this.manager.deleteMany(this.metadata.tableName, query, options)\n }\n\n /**\n * Delete a document on MongoDB.\n */\n deleteOne(\n query: ObjectLiteral,\n options?: CollectionOptions,\n ): Promise<DeleteWriteOpResultObject> {\n return this.manager.deleteOne(this.metadata.tableName, query, options)\n }\n\n /**\n * The distinct command returns returns a list of distinct values for the given key across a collection.\n */\n distinct(\n key: string,\n query: ObjectLiteral,\n options?: { readPreference?: ReadPreference | string },\n ): Promise<any> {\n return this.manager.distinct(\n this.metadata.tableName,\n key,\n query,\n options,\n )\n }\n\n /**\n * Drops an index from this collection.\n */\n dropCollectionIndex(\n indexName: string,\n options?: CollectionOptions,\n ): Promise<any> {\n return this.manager.dropCollectionIndex(\n this.metadata.tableName,\n indexName,\n options,\n )\n }\n\n /**\n * Drops all indexes from the collection.\n */\n dropCollectionIndexes(): Promise<any> {\n return this.manager.dropCollectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndDelete(\n query: ObjectLiteral,\n options?: { projection?: Object; sort?: Object; maxTimeMS?: number },\n ): Promise<FindAndModifyWriteOpResultObject> {\n return this.manager.findOneAndDelete(\n this.metadata.tableName,\n query,\n options,\n )\n }\n\n /**\n * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndReplace(\n query: ObjectLiteral,\n replacement: Object,\n options?: FindOneAndReplaceOption,\n ): Promise<FindAndModifyWriteOpResultObject> {\n return this.manager.findOneAndReplace(\n this.metadata.tableName,\n query,\n replacement,\n options,\n )\n }\n\n /**\n * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndUpdate(\n query: ObjectLiteral,\n update: Object,\n options?: FindOneAndReplaceOption,\n ): Promise<FindAndModifyWriteOpResultObject> {\n return this.manager.findOneAndUpdate(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Execute a geo search using a geo haystack index on a collection.\n */\n geoHaystackSearch(\n x: number,\n y: number,\n options?: GeoHaystackSearchOptions,\n ): Promise<any> {\n return this.manager.geoHaystackSearch(\n this.metadata.tableName,\n x,\n y,\n options,\n )\n }\n\n /**\n * Execute the geoNear command to search for items in the collection.\n */\n geoNear(x: number, y: number, options?: GeoNearOptions): Promise<any> {\n return this.manager.geoNear(this.metadata.tableName, x, y, options)\n }\n\n /**\n * Run a group command across a collection.\n */\n group(\n keys: Object | Array<any> | Function | Code,\n condition: Object,\n initial: Object,\n reduce: Function | Code,\n finalize: Function | Code,\n command: boolean,\n options?: { readPreference?: ReadPreference | string },\n ): Promise<any> {\n return this.manager.group(\n this.metadata.tableName,\n keys,\n condition,\n initial,\n reduce,\n finalize,\n command,\n options,\n )\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexes(): Promise<any> {\n return this.manager.collectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexExists(indexes: string | string[]): Promise<boolean> {\n return this.manager.collectionIndexExists(\n this.metadata.tableName,\n indexes,\n )\n }\n\n /**\n * Retrieves this collections index info.\n */\n collectionIndexInformation(options?: { full: boolean }): Promise<any> {\n return this.manager.collectionIndexInformation(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.\n */\n initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation {\n return this.manager.initializeOrderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.\n */\n initializeUnorderedBulkOp(\n options?: CollectionOptions,\n ): UnorderedBulkOperation {\n return this.manager.initializeUnorderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Inserts an array of documents into MongoDB.\n */\n insertMany(\n docs: ObjectLiteral[],\n options?: CollectionInsertManyOptions,\n ): Promise<InsertWriteOpResult> {\n return this.manager.insertMany(this.metadata.tableName, docs, options)\n }\n\n /**\n * Inserts a single document into MongoDB.\n */\n insertOne(\n doc: ObjectLiteral,\n options?: CollectionInsertOneOptions,\n ): Promise<InsertOneWriteOpResult> {\n return this.manager.insertOne(this.metadata.tableName, doc, options)\n }\n\n /**\n * Returns if the collection is a capped collection.\n */\n isCapped(): Promise<any> {\n return this.manager.isCapped(this.metadata.tableName)\n }\n\n /**\n * Get the list of all indexes information for the collection.\n */\n listCollectionIndexes(options?: {\n batchSize?: number\n readPreference?: ReadPreference | string\n }): CommandCursor {\n return this.manager.listCollectionIndexes(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.\n */\n mapReduce(\n map: Function | string,\n reduce: Function | string,\n options?: MapReduceOptions,\n ): Promise<any> {\n return this.manager.mapReduce(\n this.metadata.tableName,\n map,\n reduce,\n options,\n )\n }\n\n /**\n * Return N number of parallel cursors for a collection allowing parallel reading of entire collection.\n * There are no ordering guarantees for returned results.\n */\n parallelCollectionScan(\n options?: ParallelCollectionScanOptions,\n ): Promise<Cursor<Entity>[]> {\n return this.manager.parallelCollectionScan(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n reIndex(): Promise<any> {\n return this.manager.reIndex(this.metadata.tableName)\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n rename(\n newName: string,\n options?: { dropTarget?: boolean },\n ): Promise<Collection<any>> {\n return this.manager.rename(this.metadata.tableName, newName, options)\n }\n\n /**\n * Replace a document on MongoDB.\n */\n replaceOne(\n query: ObjectLiteral,\n doc: ObjectLiteral,\n options?: ReplaceOneOptions,\n ): Promise<UpdateWriteOpResult> {\n return this.manager.replaceOne(\n this.metadata.tableName,\n query,\n doc,\n options,\n )\n }\n\n /**\n * Get all the collection statistics.\n */\n stats(options?: { scale: number }): Promise<CollStats> {\n return this.manager.stats(this.metadata.tableName, options)\n }\n\n /**\n * Update multiple documents on MongoDB.\n */\n updateMany(\n query: ObjectLiteral,\n update: ObjectLiteral,\n options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean },\n ): Promise<UpdateWriteOpResult> {\n return this.manager.updateMany(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Update a single document on MongoDB.\n */\n updateOne(\n query: ObjectLiteral,\n update: ObjectLiteral,\n options?: ReplaceOneOptions,\n ): Promise<UpdateWriteOpResult> {\n return this.manager.updateOne(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/repository/MongoRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAKzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AA0CpD;;GAEG;AACH,MAAM,OAAO,eAEX,SAAQ,UAAkB;IAUxB,4EAA4E;IAC5E,qBAAqB;IACrB,4EAA4E;IAE5E;;;OAGG;IACH,KAAK,CAAC,KAAa,EAAE,UAAkB;QACnC,MAAM,IAAI,YAAY,CAAC,sCAAsC,CAAC,CAAA;IAClE,CAAC;IAED;;;OAGG;IACH,kBAAkB,CACd,KAAa,EACb,WAAyB;QAEzB,MAAM,IAAI,YAAY,CAAC,4CAA4C,CAAC,CAAA;IACxE,CAAC;IAED;;OAEG;IACH,IAAI,CACA,OAG6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC3D,CAAC;IAED;;;;OAIG;IACH,YAAY,CACR,O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AO,CAAC,CAAA;IAC/D,CAAC;IAED;;OAEG;IACH,UAAU,CACN,KAAoB,EACpB,MAA8B,EAC9B,OAAuB;QAEvB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC1B,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB,KAAK,EACL,MAAM,EACN,OAAO,CACV,CAAA;IACL,CAAC;IAED;;OAEG;IACH,SAAS,CACL,KAAoB,EACpB,MAA8B,EAC9B,OAAuB;QAEvB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CACzB,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB,KAAK,EACL,MAAM,EACN,OAAO,CACV,CAAA;IACL,CAAC;CACJ","file":"MongoRepository.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { Repository } from \"./Repository\"\nimport { MongoFindManyOptions } from \"../find-options/mongodb/MongoFindManyOptions\"\nimport { MongoEntityManager } from \"../entity-manager/MongoEntityManager\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { TypeORMError } from \"../error/TypeORMError\"\nimport { MongoFindOneOptions } from \"../find-options/mongodb/MongoFindOneOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\n\nimport {\n CreateIndexesOptions,\n ObjectId,\n ReplaceOptions,\n //\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BulkWriteOptions,\n BulkWriteResult,\n Collection,\n CollStats,\n CollStatsOptions,\n CommandOperationOptions,\n CountOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n Filter,\n FilterOperators,\n FindCursor,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n IndexDescription,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListIndexesOptions,\n OrderedBulkOperation,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n} from \"../driver/mongodb/typings\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\n\n/**\n * Repository used to manage mongodb documents of a single entity type.\n */\nexport class MongoRepository<\n Entity extends ObjectLiteral,\n> extends Repository<Entity> {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: MongoEntityManager\n\n // -------------------------------------------------------------------------\n // Overridden Methods\n // -------------------------------------------------------------------------\n\n /**\n * Raw SQL query execution is not supported by MongoDB.\n * Calling this method will return an error.\n */\n query(query: string, parameters?: any[]): Promise<any> {\n throw new TypeORMError(`Queries aren't supported by MongoDB.`)\n }\n\n /**\n * Using Query Builder with MongoDB is not supported yet.\n * Calling this method will return an error.\n */\n createQueryBuilder(\n alias: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n throw new TypeORMError(`Query Builder is not supported by MongoDB.`)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(\n options?:\n | FindManyOptions<Entity>\n | Partial<Entity>\n | FilterOperators<Entity>,\n ): Promise<Entity[]> {\n return this.manager.find(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n */\n findBy(where: any): Promise<Entity[]> {\n return this.manager.findBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(\n options?: MongoFindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCount(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy(where: any): Promise<[Entity[], number]> {\n return this.manager.findAndCountBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n findByIds(ids: any[], options?: any): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target, ids, options)\n }\n\n /**\n * Finds first entity that matches given find options.\n */\n async findOne(\n options: MongoFindOneOptions<Entity>,\n ): Promise<Entity | null> {\n return this.manager.findOne(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given WHERE conditions.\n */\n async findOneBy(where: any): Promise<Entity | null> {\n return this.manager.findOneBy(this.metadata.target, where)\n }\n\n /**\n * Finds entity that matches given id.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById(\n id: string | number | Date | ObjectId,\n ): Promise<Entity | null> {\n return this.manager.findOneById(this.metadata.target, id)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail(options: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail(where: any): Promise<Entity> {\n return this.manager.findOneByOrFail(this.metadata.target, where)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n */\n createCursor<T = any>(query?: Filter<Entity>): FindCursor<T> {\n return this.manager.createCursor(this.metadata.target, query)\n }\n\n /**\n * Creates a cursor for a query that can be used to iterate over results from MongoDB.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n createEntityCursor(query?: Filter<Entity>): FindCursor<Entity> {\n return this.manager.createEntityCursor(this.metadata.target, query)\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n */\n aggregate<R = any>(\n pipeline: ObjectLiteral[],\n options?: AggregateOptions,\n ): AggregationCursor<Entity> {\n return this.manager.aggregate<R>(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n\n /**\n * Execute an aggregation framework pipeline against the collection.\n * This returns modified version of cursor that transforms each result into Entity model.\n */\n aggregateEntity(\n pipeline: ObjectLiteral[],\n options?: AggregateOptions,\n ): AggregationCursor<Entity> {\n return this.manager.aggregateEntity(\n this.metadata.target,\n pipeline,\n options,\n )\n }\n /**\n * Perform a bulkWrite operation without a fluent API.\n */\n bulkWrite(\n operations: AnyBulkWriteOperation[],\n options?: BulkWriteOptions,\n ): Promise<BulkWriteResult> {\n return this.manager.bulkWrite(this.metadata.target, operations, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n count(query?: ObjectLiteral, options?: CountOptions): Promise<number> {\n return this.manager.count(this.metadata.target, query || {}, options)\n }\n\n /**\n * Count number of matching documents in the db to a query.\n */\n countBy(query?: ObjectLiteral, options?: CountOptions): Promise<number> {\n return this.manager.countBy(this.metadata.target, query, options)\n }\n\n /**\n * Creates an index on the db and collection.\n */\n createCollectionIndex(\n fieldOrSpec: string | any,\n options?: CreateIndexesOptions,\n ): Promise<string> {\n return this.manager.createCollectionIndex(\n this.metadata.target,\n fieldOrSpec,\n options,\n )\n }\n\n /**\n * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.\n * Earlier version of MongoDB will throw a command not supported error.\n * Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.\n */\n createCollectionIndexes(indexSpecs: IndexDescription[]): Promise<string[]> {\n return this.manager.createCollectionIndexes(\n this.metadata.target,\n indexSpecs,\n )\n }\n\n /**\n * Delete multiple documents on MongoDB.\n */\n deleteMany(\n query: ObjectLiteral,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.manager.deleteMany(this.metadata.tableName, query, options)\n }\n\n /**\n * Delete a document on MongoDB.\n */\n deleteOne(\n query: ObjectLiteral,\n options?: DeleteOptions,\n ): Promise<DeleteResult> {\n return this.manager.deleteOne(this.metadata.tableName, query, options)\n }\n\n /**\n * The distinct command returns returns a list of distinct values for the given key across a collection.\n */\n distinct(\n key: string,\n query: ObjectLiteral,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.manager.distinct(\n this.metadata.tableName,\n key,\n query,\n options,\n )\n }\n\n /**\n * Drops an index from this collection.\n */\n dropCollectionIndex(\n indexName: string,\n options?: CommandOperationOptions,\n ): Promise<any> {\n return this.manager.dropCollectionIndex(\n this.metadata.tableName,\n indexName,\n options,\n )\n }\n\n /**\n * Drops all indexes from the collection.\n */\n dropCollectionIndexes(): Promise<any> {\n return this.manager.dropCollectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndDelete(\n query: ObjectLiteral,\n options?: FindOneAndDeleteOptions,\n ): Promise<Document> {\n return this.manager.findOneAndDelete(\n this.metadata.tableName,\n query,\n options,\n )\n }\n\n /**\n * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndReplace(\n query: ObjectLiteral,\n replacement: Object,\n options?: FindOneAndReplaceOptions,\n ): Promise<Document> {\n return this.manager.findOneAndReplace(\n this.metadata.tableName,\n query,\n replacement,\n options,\n )\n }\n\n /**\n * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.\n */\n findOneAndUpdate(\n query: ObjectLiteral,\n update: Object,\n options?: FindOneAndUpdateOptions,\n ): Promise<Document> {\n return this.manager.findOneAndUpdate(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexes(): Promise<any> {\n return this.manager.collectionIndexes(this.metadata.tableName)\n }\n\n /**\n * Retrieve all the indexes on the collection.\n */\n collectionIndexExists(indexes: string | string[]): Promise<boolean> {\n return this.manager.collectionIndexExists(\n this.metadata.tableName,\n indexes,\n )\n }\n\n /**\n * Retrieves this collections index info.\n */\n collectionIndexInformation(options?: { full: boolean }): Promise<any> {\n return this.manager.collectionIndexInformation(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.\n */\n initializeOrderedBulkOp(options?: BulkWriteOptions): OrderedBulkOperation {\n return this.manager.initializeOrderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.\n */\n initializeUnorderedBulkOp(\n options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n return this.manager.initializeUnorderedBulkOp(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Inserts an array of documents into MongoDB.\n */\n insertMany(\n docs: ObjectLiteral[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult<Document>> {\n return this.manager.insertMany(this.metadata.tableName, docs, options)\n }\n\n /**\n * Inserts a single document into MongoDB.\n */\n insertOne(\n doc: ObjectLiteral,\n options?: InsertOneOptions,\n ): Promise<InsertOneResult> {\n return this.manager.insertOne(this.metadata.tableName, doc, options)\n }\n\n /**\n * Returns if the collection is a capped collection.\n */\n isCapped(): Promise<any> {\n return this.manager.isCapped(this.metadata.tableName)\n }\n\n /**\n * Get the list of all indexes information for the collection.\n */\n listCollectionIndexes(options?: ListIndexesOptions): ListIndexesCursor {\n return this.manager.listCollectionIndexes(\n this.metadata.tableName,\n options,\n )\n }\n\n /**\n * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.\n */\n rename(\n newName: string,\n options?: { dropTarget?: boolean },\n ): Promise<Collection<Document>> {\n return this.manager.rename(this.metadata.tableName, newName, options)\n }\n\n /**\n * Replace a document on MongoDB.\n */\n replaceOne(\n query: ObjectLiteral,\n doc: ObjectLiteral,\n options?: ReplaceOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.replaceOne(\n this.metadata.tableName,\n query,\n doc,\n options,\n )\n }\n\n /**\n * Get all the collection statistics.\n */\n stats(options?: CollStatsOptions): Promise<CollStats> {\n return this.manager.stats(this.metadata.tableName, options)\n }\n\n /**\n * Update multiple documents on MongoDB.\n */\n updateMany(\n query: ObjectLiteral,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.updateMany(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n\n /**\n * Update a single document on MongoDB.\n */\n updateOne(\n query: ObjectLiteral,\n update: UpdateFilter<Document>,\n options?: UpdateOptions,\n ): Promise<Document | UpdateResult> {\n return this.manager.updateOne(\n this.metadata.tableName,\n query,\n update,\n options,\n )\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -11,7 +11,7 @@ import { DeleteResult } from "../query-builder/result/DeleteResult";
|
|
|
11
11
|
import { UpdateResult } from "../query-builder/result/UpdateResult";
|
|
12
12
|
import { InsertResult } from "../query-builder/result/InsertResult";
|
|
13
13
|
import { QueryDeepPartialEntity } from "../query-builder/QueryPartialEntity";
|
|
14
|
-
import {
|
|
14
|
+
import { ObjectId } from "../driver/mongodb/typings";
|
|
15
15
|
import { FindOptionsWhere } from "../find-options/FindOptionsWhere";
|
|
16
16
|
import { UpsertOptions } from "./UpsertOptions";
|
|
17
17
|
import { EntityTarget } from "../common/EntityTarget";
|
|
@@ -165,7 +165,7 @@ export declare class Repository<Entity extends ObjectLiteral> {
|
|
|
165
165
|
* Executes fast and efficient UPDATE query.
|
|
166
166
|
* Does not check if entity exist in the database.
|
|
167
167
|
*/
|
|
168
|
-
update(criteria: string | string[] | number | number[] | Date | Date[] |
|
|
168
|
+
update(criteria: string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult>;
|
|
169
169
|
/**
|
|
170
170
|
* Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
|
|
171
171
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
@@ -178,21 +178,21 @@ export declare class Repository<Entity extends ObjectLiteral> {
|
|
|
178
178
|
* Executes fast and efficient DELETE query.
|
|
179
179
|
* Does not check if entity exist in the database.
|
|
180
180
|
*/
|
|
181
|
-
delete(criteria: string | string[] | number | number[] | Date | Date[] |
|
|
181
|
+
delete(criteria: string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<Entity>): Promise<DeleteResult>;
|
|
182
182
|
/**
|
|
183
183
|
* Records the delete date of entities by a given criteria.
|
|
184
184
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
185
185
|
* Executes fast and efficient SOFT-DELETE query.
|
|
186
186
|
* Does not check if entity exist in the database.
|
|
187
187
|
*/
|
|
188
|
-
softDelete(criteria: string | string[] | number | number[] | Date | Date[] |
|
|
188
|
+
softDelete(criteria: string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<Entity>): Promise<UpdateResult>;
|
|
189
189
|
/**
|
|
190
190
|
* Restores entities by a given criteria.
|
|
191
191
|
* Unlike save method executes a primitive operation without cascades, relations and other operations included.
|
|
192
192
|
* Executes fast and efficient SOFT-DELETE query.
|
|
193
193
|
* Does not check if entity exist in the database.
|
|
194
194
|
*/
|
|
195
|
-
restore(criteria: string | string[] | number | number[] | Date | Date[] |
|
|
195
|
+
restore(criteria: string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<Entity>): Promise<UpdateResult>;
|
|
196
196
|
/**
|
|
197
197
|
* Checks whether any entity exists that match given options.
|
|
198
198
|
*/
|
|
@@ -274,7 +274,7 @@ export declare class Repository<Entity extends ObjectLiteral> {
|
|
|
274
274
|
* id: 1 // where "id" is your primary column name
|
|
275
275
|
* })
|
|
276
276
|
*/
|
|
277
|
-
findOneById(id: number | string | Date |
|
|
277
|
+
findOneById(id: number | string | Date | ObjectId): Promise<Entity | null>;
|
|
278
278
|
/**
|
|
279
279
|
* Finds first entity by a given find options.
|
|
280
280
|
* If entity was not found in the database - rejects with error.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/repository/Repository.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,MAAM,OAAO,UAAU;IAsBnB,4EAA4E;IAC5E,YAAY;IACZ,4EAA4E;IAE5E;;OAEG;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OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;IAED;;OAEG;IACH,SAAS,CACL,UAAoC,EACpC,YAAoB,EACpB,KAAsB;QAEtB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,EACpB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAA;IACL,CAAC;IAED;;OAEG;IACH,SAAS,CACL,UAAoC,EACpC,YAAoB,EACpB,KAAsB;QAEtB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,EACpB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAA;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CACF,MAA4D;QAE5D,WAAW;QACX,eAAe;QACf,gBAAgB;QAChB,KAAK;QACL,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAkD,CAAA;QACxE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAM,SAAQ,QAAQ;SAAG,CAAC,CACvC,MAAM,EACN,OAAO,EACP,WAAW,CACd,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC1B,OAAO,GAAU,CAAA;IACrB,CAAC;CACJ","file":"Repository.js","sourcesContent":["import { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { EntityManager } from \"../entity-manager/EntityManager\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity target that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n readonly target: EntityTarget<Entity>\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n get metadata() {\n return this.manager.connection.getMetadata(this.target)\n }\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n target: EntityTarget<Entity>,\n manager: EntityManager,\n queryRunner?: QueryRunner,\n ) {\n this.target = target\n this.manager = manager\n this.queryRunner = queryRunner\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(\n this.metadata.target as any,\n alias || this.metadata.targetName,\n queryRunner || this.queryRunner,\n )\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity)\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): Entity\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create(\n plainEntityLikeOrPlainEntityLikes?:\n | DeepPartial<Entity>\n | DeepPartial<Entity>[],\n ): Entity | Entity[] {\n return this.manager.create<any>(\n this.metadata.target as any,\n plainEntityLikeOrPlainEntityLikes as any,\n )\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(\n mergeIntoEntity: Entity,\n ...entityLikes: DeepPartial<Entity>[]\n ): Entity {\n return this.manager.merge(\n this.metadata.target as any,\n mergeIntoEntity,\n ...entityLikes,\n )\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n preload(entityLike: DeepPartial<Entity>): Promise<Entity | undefined> {\n return this.manager.preload(this.metadata.target as any, entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ): Promise<T | T[]> {\n return this.manager.save<Entity, T>(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes one or many given entities.\n */\n remove(\n entityOrEntities: Entity | Entity[],\n options?: RemoveOptions,\n ): Promise<Entity | Entity[]> {\n return this.manager.remove(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ): Promise<T | T[]> {\n return this.manager.softRemove<Entity, T>(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ): Promise<T | T[]> {\n return this.manager.recover<Entity, T>(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n insert(\n entity:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n ): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n update(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<Entity>,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n return this.manager.update(\n this.metadata.target as any,\n criteria as any,\n partialEntity,\n )\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n upsert(\n entityOrEntities:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>,\n ): Promise<InsertResult> {\n return this.manager.upsert(\n this.metadata.target as any,\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n delete(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<Entity>,\n ): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any)\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<Entity>,\n ): Promise<UpdateResult> {\n return this.manager.softDelete(\n this.metadata.target as any,\n criteria as any,\n )\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<Entity>,\n ): Promise<UpdateResult> {\n return this.manager.restore(\n this.metadata.target as any,\n criteria as any,\n )\n }\n\n /**\n * Checks whether any entity exists that match given options.\n */\n exist(options?: FindManyOptions<Entity>): Promise<boolean> {\n return this.manager.exists(this.metadata.target, options)\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count(options?: FindManyOptions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target, options)\n }\n\n /**\n * Counts entities that match given conditions.\n * Useful for pagination.\n */\n countBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number> {\n return this.manager.countBy(this.metadata.target, where)\n }\n\n /**\n * Return the SUM of a column\n */\n sum(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.sum(this.metadata.target, columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n average(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.average(this.metadata.target, columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n minimum(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.minimum(this.metadata.target, columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n maximum(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.maximum(this.metadata.target, columnName, where)\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find(options?: FindManyOptions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options.\n */\n async findBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity[]> {\n return this.manager.findBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(\n options?: FindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCount(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCountBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities with ids.\n * Optionally find options or conditions can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n async findByIds(ids: any[]): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target, ids)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - returns null.\n */\n async findOne(options: FindOneOptions<Entity>): Promise<Entity | null> {\n return this.manager.findOne(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - returns null.\n */\n async findOneBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity | null> {\n return this.manager.findOneBy(this.metadata.target, where)\n }\n\n /**\n * Finds first entity that matches given id.\n * If entity was not found in the database - returns null.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById(\n id: number | string | Date | ObjectID,\n ): Promise<Entity | null> {\n return this.manager.findOneById(this.metadata.target, id)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail(options: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity> {\n return this.manager.findOneByOrFail(this.metadata.target, where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n clear(): Promise<void> {\n return this.manager.clear(this.metadata.target)\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(\n conditions: FindOptionsWhere<Entity>,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n return this.manager.increment(\n this.metadata.target,\n conditions,\n propertyPath,\n value,\n )\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(\n conditions: FindOptionsWhere<Entity>,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n return this.manager.decrement(\n this.metadata.target,\n conditions,\n propertyPath,\n value,\n )\n }\n\n /**\n * Extends repository with provided functions.\n */\n extend<CustomRepository>(\n custom: CustomRepository & ThisType<this & CustomRepository>,\n ): this & CustomRepository {\n // return {\n // ...this,\n // ...custom\n // };\n const thisRepo = this.constructor as new (...args: any[]) => typeof this\n const { target, manager, queryRunner } = this\n const cls = new (class extends thisRepo {})(\n target,\n manager,\n queryRunner,\n )\n Object.assign(cls, custom)\n return cls as any\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/repository/Repository.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,MAAM,OAAO,UAAU;IAsBnB,4EAA4E;IAC5E,YAAY;IACZ,4EAA4E;IAE5E;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3D,CAAC;IAED,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACI,MAA4B,EAC5B,OAAsB,EACtB,WAAyB;QAEzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAClC,CAAC;IAED,4EAA4E;IAC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,OAAO,CAAC,SAAS,CACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,EACpB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAA;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CACF,MAA4D;QAE5D,WAAW;QACX,eAAe;QACf,gBAAgB;QAChB,KAAK;QACL,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAkD,CAAA;QACxE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAM,SAAQ,QAAQ;SAAG,CAAC,CACvC,MAAM,EACN,OAAO,EACP,WAAW,CACd,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC1B,OAAO,GAAU,CAAA;IACrB,CAAC;CACJ","file":"Repository.js","sourcesContent":["import { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { EntityManager } from \"../entity-manager/EntityManager\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { ObjectId } from \"../driver/mongodb/typings\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity target that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n readonly target: EntityTarget<Entity>\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner\n\n // -------------------------------------------------------------------------\n // Accessors\n // -------------------------------------------------------------------------\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n get metadata() {\n return this.manager.connection.getMetadata(this.target)\n }\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n target: EntityTarget<Entity>,\n manager: EntityManager,\n queryRunner?: QueryRunner,\n ) {\n this.target = target\n this.manager = manager\n this.queryRunner = queryRunner\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(\n alias?: string,\n queryRunner?: QueryRunner,\n ): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(\n this.metadata.target as any,\n alias || this.metadata.targetName,\n queryRunner || this.queryRunner,\n )\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity)\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): Entity\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create(\n plainEntityLikeOrPlainEntityLikes?:\n | DeepPartial<Entity>\n | DeepPartial<Entity>[],\n ): Entity | Entity[] {\n return this.manager.create<any>(\n this.metadata.target as any,\n plainEntityLikeOrPlainEntityLikes as any,\n )\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(\n mergeIntoEntity: Entity,\n ...entityLikes: DeepPartial<Entity>[]\n ): Entity {\n return this.manager.merge(\n this.metadata.target as any,\n mergeIntoEntity,\n ...entityLikes,\n )\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n preload(entityLike: DeepPartial<Entity>): Promise<Entity | undefined> {\n return this.manager.preload(this.metadata.target as any, entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save<T extends DeepPartial<Entity>>(\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ): Promise<T | T[]> {\n return this.manager.save<Entity, T>(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>\n\n /**\n * Removes one or many given entities.\n */\n remove(\n entityOrEntities: Entity | Entity[],\n options?: RemoveOptions,\n ): Promise<Entity | Entity[]> {\n return this.manager.remove(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ): Promise<T | T[]> {\n return this.manager.softRemove<Entity, T>(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entities: T[],\n options: SaveOptions & { reload: false },\n ): Promise<T[]>\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entities: T[],\n options?: SaveOptions,\n ): Promise<(T & Entity)[]>\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entity: T,\n options: SaveOptions & { reload: false },\n ): Promise<T>\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(\n entity: T,\n options?: SaveOptions,\n ): Promise<T & Entity>\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ): Promise<T | T[]> {\n return this.manager.recover<Entity, T>(\n this.metadata.target as any,\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n insert(\n entity:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n ): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n update(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere<Entity>,\n partialEntity: QueryDeepPartialEntity<Entity>,\n ): Promise<UpdateResult> {\n return this.manager.update(\n this.metadata.target as any,\n criteria as any,\n partialEntity,\n )\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n upsert(\n entityOrEntities:\n | QueryDeepPartialEntity<Entity>\n | QueryDeepPartialEntity<Entity>[],\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>,\n ): Promise<InsertResult> {\n return this.manager.upsert(\n this.metadata.target as any,\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n delete(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere<Entity>,\n ): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any)\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere<Entity>,\n ): Promise<UpdateResult> {\n return this.manager.softDelete(\n this.metadata.target as any,\n criteria as any,\n )\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere<Entity>,\n ): Promise<UpdateResult> {\n return this.manager.restore(\n this.metadata.target as any,\n criteria as any,\n )\n }\n\n /**\n * Checks whether any entity exists that match given options.\n */\n exist(options?: FindManyOptions<Entity>): Promise<boolean> {\n return this.manager.exists(this.metadata.target, options)\n }\n\n /**\n * Counts entities that match given options.\n * Useful for pagination.\n */\n count(options?: FindManyOptions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target, options)\n }\n\n /**\n * Counts entities that match given conditions.\n * Useful for pagination.\n */\n countBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number> {\n return this.manager.countBy(this.metadata.target, where)\n }\n\n /**\n * Return the SUM of a column\n */\n sum(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.sum(this.metadata.target, columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n average(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.average(this.metadata.target, columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n minimum(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.minimum(this.metadata.target, columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n maximum(\n columnName: PickKeysByType<Entity, number>,\n where?: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<number | null> {\n return this.manager.maximum(this.metadata.target, columnName, where)\n }\n\n /**\n * Finds entities that match given find options.\n */\n async find(options?: FindManyOptions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given find options.\n */\n async findBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity[]> {\n return this.manager.findBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(\n options?: FindManyOptions<Entity>,\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCount(this.metadata.target, options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCountBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<[Entity[], number]> {\n return this.manager.findAndCountBy(this.metadata.target, where)\n }\n\n /**\n * Finds entities with ids.\n * Optionally find options or conditions can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n async findByIds(ids: any[]): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target, ids)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - returns null.\n */\n async findOne(options: FindOneOptions<Entity>): Promise<Entity | null> {\n return this.manager.findOne(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - returns null.\n */\n async findOneBy(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity | null> {\n return this.manager.findOneBy(this.metadata.target, where)\n }\n\n /**\n * Finds first entity that matches given id.\n * If entity was not found in the database - returns null.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n async findOneById(\n id: number | string | Date | ObjectId,\n ): Promise<Entity | null> {\n return this.manager.findOneById(this.metadata.target, id)\n }\n\n /**\n * Finds first entity by a given find options.\n * If entity was not found in the database - rejects with error.\n */\n async findOneOrFail(options: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target, options)\n }\n\n /**\n * Finds first entity that matches given where condition.\n * If entity was not found in the database - rejects with error.\n */\n async findOneByOrFail(\n where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],\n ): Promise<Entity> {\n return this.manager.findOneByOrFail(this.metadata.target, where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n clear(): Promise<void> {\n return this.manager.clear(this.metadata.target)\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(\n conditions: FindOptionsWhere<Entity>,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n return this.manager.increment(\n this.metadata.target,\n conditions,\n propertyPath,\n value,\n )\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(\n conditions: FindOptionsWhere<Entity>,\n propertyPath: string,\n value: number | string,\n ): Promise<UpdateResult> {\n return this.manager.decrement(\n this.metadata.target,\n conditions,\n propertyPath,\n value,\n )\n }\n\n /**\n * Extends repository with provided functions.\n */\n extend<CustomRepository>(\n custom: CustomRepository & ThisType<this & CustomRepository>,\n ): this & CustomRepository {\n // return {\n // ...this,\n // ...custom\n // };\n const thisRepo = this.constructor as new (...args: any[]) => typeof this\n const { target, manager, queryRunner } = this\n const cls = new (class extends thisRepo {})(\n target,\n manager,\n queryRunner,\n )\n Object.assign(cls, custom)\n return cls as any\n }\n}\n"],"sourceRoot":".."}
|