typeorm 0.3.15-dev.115059d → 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 +6 -4
- 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,13 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { QueryRunner } from "../../query-runner/QueryRunner";
|
|
3
|
-
import { ObjectLiteral } from "../../common/ObjectLiteral";
|
|
4
3
|
import { TableColumn } from "../../schema-builder/table/TableColumn";
|
|
5
4
|
import { Table } from "../../schema-builder/table/Table";
|
|
6
5
|
import { TableForeignKey } from "../../schema-builder/table/TableForeignKey";
|
|
7
6
|
import { TableIndex } from "../../schema-builder/table/TableIndex";
|
|
8
7
|
import { View } from "../../schema-builder/view/View";
|
|
9
|
-
import { AggregationCursor, BulkWriteOpResultObject, ChangeStream, ChangeStreamOptions, Code, Collection, CollectionAggregationOptions, CollectionBulkWriteOptions, CollectionInsertManyOptions, CollectionInsertOneOptions, CollectionOptions, CollStats, CommandCursor, Cursor, DeleteWriteOpResultObject, FindAndModifyWriteOpResultObject, FindOneAndReplaceOption, GeoHaystackSearchOptions, GeoNearOptions, InsertOneWriteOpResult, InsertWriteOpResult, MapReduceOptions, MongoClient, MongoCountPreferences, MongodbIndexOptions, OrderedBulkOperation, ParallelCollectionScanOptions, ReadPreference, ReplaceOneOptions, UnorderedBulkOperation, UpdateWriteOpResult } from "./typings";
|
|
10
|
-
import { DataSource } from "../../data-source/DataSource";
|
|
11
8
|
import { ReadStream } from "../../platform/PlatformTools";
|
|
12
9
|
import { MongoEntityManager } from "../../entity-manager/MongoEntityManager";
|
|
13
10
|
import { SqlInMemory } from "../SqlInMemory";
|
|
@@ -15,6 +12,8 @@ import { TableUnique } from "../../schema-builder/table/TableUnique";
|
|
|
15
12
|
import { Broadcaster } from "../../subscriber/Broadcaster";
|
|
16
13
|
import { TableCheck } from "../../schema-builder/table/TableCheck";
|
|
17
14
|
import { TableExclusion } from "../../schema-builder/table/TableExclusion";
|
|
15
|
+
import { BulkWriteResult, AggregationCursor, MongoClient, Collection, FindCursor, Document, AggregateOptions, AnyBulkWriteOperation, BulkWriteOptions, Filter, CountOptions, CountDocumentsOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, DeleteResult, DeleteOptions, CommandOperationOptions, FindOneAndDeleteOptions, FindOneAndReplaceOptions, UpdateFilter, FindOneAndUpdateOptions, RenameOptions, ReplaceOptions, UpdateResult, CollStats, CollStatsOptions, ChangeStreamOptions, ChangeStream, UpdateOptions, ListIndexesOptions, ListIndexesCursor, OptionalId, InsertOneOptions, InsertOneResult, InsertManyResult, UnorderedBulkOperation, OrderedBulkOperation, IndexInformationOptions } from "../../driver/mongodb/typings";
|
|
16
|
+
import { DataSource } from "../../data-source/DataSource";
|
|
18
17
|
import { ReplicationMode } from "../types/ReplicationMode";
|
|
19
18
|
/**
|
|
20
19
|
* Runs queries on a single MongoDB connection.
|
|
@@ -72,84 +71,68 @@ export declare class MongoQueryRunner implements QueryRunner {
|
|
|
72
71
|
/**
|
|
73
72
|
* Creates a cursor for a query that can be used to iterate over results from MongoDB.
|
|
74
73
|
*/
|
|
75
|
-
cursor(collectionName: string,
|
|
74
|
+
cursor(collectionName: string, filter: Filter<Document>): FindCursor<any>;
|
|
76
75
|
/**
|
|
77
76
|
* Execute an aggregation framework pipeline against the collection.
|
|
78
77
|
*/
|
|
79
|
-
aggregate(collectionName: string, pipeline:
|
|
78
|
+
aggregate(collectionName: string, pipeline: Document[], options?: AggregateOptions): AggregationCursor<any>;
|
|
80
79
|
/**
|
|
81
80
|
* Perform a bulkWrite operation without a fluent API.
|
|
82
81
|
*/
|
|
83
|
-
bulkWrite(collectionName: string, operations:
|
|
82
|
+
bulkWrite(collectionName: string, operations: AnyBulkWriteOperation<Document>[], options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Count number of matching documents in the db to a query.
|
|
85
|
+
*/
|
|
86
|
+
count(collectionName: string, filter: Filter<Document>, options?: CountOptions): Promise<number>;
|
|
84
87
|
/**
|
|
85
88
|
* Count number of matching documents in the db to a query.
|
|
86
89
|
*/
|
|
87
|
-
|
|
90
|
+
countDocuments(collectionName: string, filter: Filter<Document>, options?: CountDocumentsOptions): Promise<any>;
|
|
88
91
|
/**
|
|
89
92
|
* Creates an index on the db and collection.
|
|
90
93
|
*/
|
|
91
|
-
createCollectionIndex(collectionName: string,
|
|
94
|
+
createCollectionIndex(collectionName: string, indexSpec: IndexSpecification, options?: CreateIndexesOptions): Promise<string>;
|
|
92
95
|
/**
|
|
93
96
|
* Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.
|
|
94
97
|
* Earlier version of MongoDB will throw a command not supported error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.
|
|
95
98
|
*/
|
|
96
|
-
createCollectionIndexes(collectionName: string, indexSpecs:
|
|
99
|
+
createCollectionIndexes(collectionName: string, indexSpecs: IndexDescription[]): Promise<string[]>;
|
|
97
100
|
/**
|
|
98
101
|
* Delete multiple documents on MongoDB.
|
|
99
102
|
*/
|
|
100
|
-
deleteMany(collectionName: string,
|
|
103
|
+
deleteMany(collectionName: string, filter: Filter<Document>, options: DeleteOptions): Promise<DeleteResult>;
|
|
101
104
|
/**
|
|
102
105
|
* Delete a document on MongoDB.
|
|
103
106
|
*/
|
|
104
|
-
deleteOne(collectionName: string,
|
|
107
|
+
deleteOne(collectionName: string, filter: Filter<Document>, options?: DeleteOptions): Promise<DeleteResult>;
|
|
105
108
|
/**
|
|
106
109
|
* The distinct command returns returns a list of distinct values for the given key across a collection.
|
|
107
110
|
*/
|
|
108
|
-
distinct(collectionName: string, key:
|
|
109
|
-
readPreference?: ReadPreference | string;
|
|
110
|
-
}): Promise<any>;
|
|
111
|
+
distinct(collectionName: string, key: any, filter: Filter<Document>, options?: CommandOperationOptions): Promise<any>;
|
|
111
112
|
/**
|
|
112
113
|
* Drops an index from this collection.
|
|
113
114
|
*/
|
|
114
|
-
dropCollectionIndex(collectionName: string, indexName: string, options?:
|
|
115
|
+
dropCollectionIndex(collectionName: string, indexName: string, options?: CommandOperationOptions): Promise<Document>;
|
|
115
116
|
/**
|
|
116
117
|
* Drops all indexes from the collection.
|
|
117
118
|
*/
|
|
118
|
-
dropCollectionIndexes(collectionName: string): Promise<
|
|
119
|
+
dropCollectionIndexes(collectionName: string): Promise<Document>;
|
|
119
120
|
/**
|
|
120
121
|
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
|
|
121
122
|
*/
|
|
122
|
-
findOneAndDelete(collectionName: string,
|
|
123
|
-
projection?: Object;
|
|
124
|
-
sort?: Object;
|
|
125
|
-
maxTimeMS?: number;
|
|
126
|
-
}): Promise<FindAndModifyWriteOpResultObject>;
|
|
123
|
+
findOneAndDelete(collectionName: string, filter: Filter<Document>, options?: FindOneAndDeleteOptions): Promise<Document>;
|
|
127
124
|
/**
|
|
128
125
|
* Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
|
|
129
126
|
*/
|
|
130
|
-
findOneAndReplace(collectionName: string,
|
|
127
|
+
findOneAndReplace(collectionName: string, filter: Filter<Document>, replacement: Document, options?: FindOneAndReplaceOptions): Promise<Document>;
|
|
131
128
|
/**
|
|
132
129
|
* Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
|
|
133
130
|
*/
|
|
134
|
-
findOneAndUpdate(collectionName: string,
|
|
135
|
-
/**
|
|
136
|
-
* Execute a geo search using a geo haystack index on a collection.
|
|
137
|
-
*/
|
|
138
|
-
geoHaystackSearch(collectionName: string, x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
|
|
139
|
-
/**
|
|
140
|
-
* Execute the geoNear command to search for items in the collection.
|
|
141
|
-
*/
|
|
142
|
-
geoNear(collectionName: string, x: number, y: number, options?: GeoNearOptions): Promise<any>;
|
|
143
|
-
/**
|
|
144
|
-
* Run a group command across a collection.
|
|
145
|
-
*/
|
|
146
|
-
group(collectionName: string, keys: Object | Array<any> | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: {
|
|
147
|
-
readPreference?: ReadPreference | string;
|
|
148
|
-
}): Promise<any>;
|
|
131
|
+
findOneAndUpdate(collectionName: string, filter: Filter<Document>, update: UpdateFilter<Document>, options?: FindOneAndUpdateOptions): Promise<Document>;
|
|
149
132
|
/**
|
|
150
133
|
* Retrieve all the indexes on the collection.
|
|
151
134
|
*/
|
|
152
|
-
collectionIndexes(collectionName: string): Promise<
|
|
135
|
+
collectionIndexes(collectionName: string): Promise<Document>;
|
|
153
136
|
/**
|
|
154
137
|
* Retrieve all the indexes on the collection.
|
|
155
138
|
*/
|
|
@@ -157,82 +140,55 @@ export declare class MongoQueryRunner implements QueryRunner {
|
|
|
157
140
|
/**
|
|
158
141
|
* Retrieves this collections index info.
|
|
159
142
|
*/
|
|
160
|
-
collectionIndexInformation(collectionName: string, options?:
|
|
161
|
-
full: boolean;
|
|
162
|
-
}): Promise<any>;
|
|
143
|
+
collectionIndexInformation(collectionName: string, options?: IndexInformationOptions): Promise<any>;
|
|
163
144
|
/**
|
|
164
145
|
* 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.
|
|
165
146
|
*/
|
|
166
|
-
initializeOrderedBulkOp(collectionName: string, options?:
|
|
147
|
+
initializeOrderedBulkOp(collectionName: string, options?: BulkWriteOptions): OrderedBulkOperation;
|
|
167
148
|
/**
|
|
168
149
|
* Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
|
|
169
150
|
*/
|
|
170
|
-
initializeUnorderedBulkOp(collectionName: string, options?:
|
|
151
|
+
initializeUnorderedBulkOp(collectionName: string, options?: BulkWriteOptions): UnorderedBulkOperation;
|
|
171
152
|
/**
|
|
172
153
|
* Inserts an array of documents into MongoDB.
|
|
173
154
|
*/
|
|
174
|
-
insertMany(collectionName: string, docs:
|
|
155
|
+
insertMany(collectionName: string, docs: OptionalId<Document>[], options?: BulkWriteOptions): Promise<InsertManyResult>;
|
|
175
156
|
/**
|
|
176
157
|
* Inserts a single document into MongoDB.
|
|
177
158
|
*/
|
|
178
|
-
insertOne(collectionName: string, doc:
|
|
159
|
+
insertOne(collectionName: string, doc: OptionalId<Document>, options?: InsertOneOptions): Promise<InsertOneResult>;
|
|
179
160
|
/**
|
|
180
161
|
* Returns if the collection is a capped collection.
|
|
181
162
|
*/
|
|
182
|
-
isCapped(collectionName: string): Promise<
|
|
163
|
+
isCapped(collectionName: string): Promise<boolean>;
|
|
183
164
|
/**
|
|
184
165
|
* Get the list of all indexes information for the collection.
|
|
185
166
|
*/
|
|
186
|
-
listCollectionIndexes(collectionName: string, options?:
|
|
187
|
-
batchSize?: number;
|
|
188
|
-
readPreference?: ReadPreference | string;
|
|
189
|
-
}): CommandCursor;
|
|
190
|
-
/**
|
|
191
|
-
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
|
|
192
|
-
*/
|
|
193
|
-
mapReduce(collectionName: string, map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise<any>;
|
|
194
|
-
/**
|
|
195
|
-
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
|
|
196
|
-
* There are no ordering guarantees for returned results.
|
|
197
|
-
*/
|
|
198
|
-
parallelCollectionScan(collectionName: string, options?: ParallelCollectionScanOptions): Promise<Cursor<any>[]>;
|
|
199
|
-
/**
|
|
200
|
-
* 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.
|
|
201
|
-
*/
|
|
202
|
-
reIndex(collectionName: string): Promise<any>;
|
|
167
|
+
listCollectionIndexes(collectionName: string, options?: ListIndexesOptions): ListIndexesCursor;
|
|
203
168
|
/**
|
|
204
169
|
* 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.
|
|
205
170
|
*/
|
|
206
|
-
rename(collectionName: string, newName: string, options?:
|
|
207
|
-
dropTarget?: boolean;
|
|
208
|
-
}): Promise<Collection<any>>;
|
|
171
|
+
rename(collectionName: string, newName: string, options?: RenameOptions): Promise<Collection<Document>>;
|
|
209
172
|
/**
|
|
210
173
|
* Replace a document on MongoDB.
|
|
211
174
|
*/
|
|
212
|
-
replaceOne(collectionName: string,
|
|
175
|
+
replaceOne(collectionName: string, filter: Filter<Document>, replacement: Document, options?: ReplaceOptions): Promise<Document | UpdateResult>;
|
|
213
176
|
/**
|
|
214
177
|
* Get all the collection statistics.
|
|
215
178
|
*/
|
|
216
|
-
stats(collectionName: string, options?:
|
|
217
|
-
scale: number;
|
|
218
|
-
}): Promise<CollStats>;
|
|
179
|
+
stats(collectionName: string, options?: CollStatsOptions): Promise<CollStats>;
|
|
219
180
|
/**
|
|
220
181
|
* Watching new changes as stream.
|
|
221
182
|
*/
|
|
222
|
-
watch(collectionName: string, pipeline?:
|
|
183
|
+
watch(collectionName: string, pipeline?: Document[], options?: ChangeStreamOptions): ChangeStream;
|
|
223
184
|
/**
|
|
224
185
|
* Update multiple documents on MongoDB.
|
|
225
186
|
*/
|
|
226
|
-
updateMany(collectionName: string,
|
|
227
|
-
upsert?: boolean;
|
|
228
|
-
w?: any;
|
|
229
|
-
wtimeout?: number;
|
|
230
|
-
j?: boolean;
|
|
231
|
-
}): Promise<UpdateWriteOpResult>;
|
|
187
|
+
updateMany(collectionName: string, filter: Filter<Document>, update: UpdateFilter<Document>, options?: UpdateOptions): Promise<Document | UpdateResult>;
|
|
232
188
|
/**
|
|
233
189
|
* Update a single document on MongoDB.
|
|
234
190
|
*/
|
|
235
|
-
updateOne(collectionName: string,
|
|
191
|
+
updateOne(collectionName: string, filter: Filter<Document>, update: UpdateFilter<Document>, options?: UpdateOptions): Promise<Document | UpdateResult>;
|
|
236
192
|
/**
|
|
237
193
|
* Removes all collections from the currently connected database.
|
|
238
194
|
* Be careful with using this method and avoid using it in production or migrations
|
|
@@ -46,123 +46,111 @@ export class MongoQueryRunner {
|
|
|
46
46
|
/**
|
|
47
47
|
* Creates a cursor for a query that can be used to iterate over results from MongoDB.
|
|
48
48
|
*/
|
|
49
|
-
cursor(collectionName,
|
|
50
|
-
return this.getCollection(collectionName).find(
|
|
49
|
+
cursor(collectionName, filter) {
|
|
50
|
+
return this.getCollection(collectionName).find(filter || {});
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Execute an aggregation framework pipeline against the collection.
|
|
54
54
|
*/
|
|
55
55
|
aggregate(collectionName, pipeline, options) {
|
|
56
|
-
return this.getCollection(collectionName).aggregate(pipeline, options);
|
|
56
|
+
return this.getCollection(collectionName).aggregate(pipeline, options || {});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Perform a bulkWrite operation without a fluent API.
|
|
60
60
|
*/
|
|
61
61
|
async bulkWrite(collectionName, operations, options) {
|
|
62
|
-
return await this.getCollection(collectionName).bulkWrite(operations, options);
|
|
62
|
+
return await this.getCollection(collectionName).bulkWrite(operations, options || {});
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Count number of matching documents in the db to a query.
|
|
66
66
|
*/
|
|
67
|
-
async count(collectionName,
|
|
68
|
-
return
|
|
67
|
+
async count(collectionName, filter, options) {
|
|
68
|
+
return this.getCollection(collectionName).count(filter || {}, options || {});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Count number of matching documents in the db to a query.
|
|
72
|
+
*/
|
|
73
|
+
async countDocuments(collectionName, filter, options) {
|
|
74
|
+
return this.getCollection(collectionName).countDocuments(filter || {}, options || {});
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
71
77
|
* Creates an index on the db and collection.
|
|
72
78
|
*/
|
|
73
|
-
async createCollectionIndex(collectionName,
|
|
74
|
-
return
|
|
79
|
+
async createCollectionIndex(collectionName, indexSpec, options) {
|
|
80
|
+
return this.getCollection(collectionName).createIndex(indexSpec, options || {});
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
83
|
* Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.
|
|
78
84
|
* Earlier version of MongoDB will throw a command not supported error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.
|
|
79
85
|
*/
|
|
80
86
|
async createCollectionIndexes(collectionName, indexSpecs) {
|
|
81
|
-
return
|
|
87
|
+
return this.getCollection(collectionName).createIndexes(indexSpecs);
|
|
82
88
|
}
|
|
83
89
|
/**
|
|
84
90
|
* Delete multiple documents on MongoDB.
|
|
85
91
|
*/
|
|
86
|
-
async deleteMany(collectionName,
|
|
87
|
-
return
|
|
92
|
+
async deleteMany(collectionName, filter, options) {
|
|
93
|
+
return this.getCollection(collectionName).deleteMany(filter, options || {});
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
96
|
* Delete a document on MongoDB.
|
|
91
97
|
*/
|
|
92
|
-
async deleteOne(collectionName,
|
|
93
|
-
return
|
|
98
|
+
async deleteOne(collectionName, filter, options) {
|
|
99
|
+
return this.getCollection(collectionName).deleteOne(filter, options || {});
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
102
|
* The distinct command returns returns a list of distinct values for the given key across a collection.
|
|
97
103
|
*/
|
|
98
|
-
async distinct(collectionName, key,
|
|
99
|
-
return
|
|
104
|
+
async distinct(collectionName, key, filter, options) {
|
|
105
|
+
return this.getCollection(collectionName).distinct(key, filter, options || {});
|
|
100
106
|
}
|
|
101
107
|
/**
|
|
102
108
|
* Drops an index from this collection.
|
|
103
109
|
*/
|
|
104
110
|
async dropCollectionIndex(collectionName, indexName, options) {
|
|
105
|
-
return
|
|
111
|
+
return this.getCollection(collectionName).dropIndex(indexName, options || {});
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
114
|
* Drops all indexes from the collection.
|
|
109
115
|
*/
|
|
110
116
|
async dropCollectionIndexes(collectionName) {
|
|
111
|
-
return
|
|
117
|
+
return this.getCollection(collectionName).dropIndexes();
|
|
112
118
|
}
|
|
113
119
|
/**
|
|
114
120
|
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
|
|
115
121
|
*/
|
|
116
|
-
async findOneAndDelete(collectionName,
|
|
117
|
-
return
|
|
122
|
+
async findOneAndDelete(collectionName, filter, options) {
|
|
123
|
+
return this.getCollection(collectionName).findOneAndDelete(filter, options || {});
|
|
118
124
|
}
|
|
119
125
|
/**
|
|
120
126
|
* Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
|
|
121
127
|
*/
|
|
122
|
-
async findOneAndReplace(collectionName,
|
|
123
|
-
return
|
|
128
|
+
async findOneAndReplace(collectionName, filter, replacement, options) {
|
|
129
|
+
return this.getCollection(collectionName).findOneAndReplace(filter, replacement, options || {});
|
|
124
130
|
}
|
|
125
131
|
/**
|
|
126
132
|
* Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
|
|
127
133
|
*/
|
|
128
|
-
async findOneAndUpdate(collectionName,
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Execute a geo search using a geo haystack index on a collection.
|
|
133
|
-
*/
|
|
134
|
-
async geoHaystackSearch(collectionName, x, y, options) {
|
|
135
|
-
return await this.getCollection(collectionName).geoHaystackSearch(x, y, options);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Execute the geoNear command to search for items in the collection.
|
|
139
|
-
*/
|
|
140
|
-
async geoNear(collectionName, x, y, options) {
|
|
141
|
-
return await this.getCollection(collectionName).geoNear(x, y, options);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Run a group command across a collection.
|
|
145
|
-
*/
|
|
146
|
-
async group(collectionName, keys, condition, initial, reduce, finalize, command, options) {
|
|
147
|
-
return await this.getCollection(collectionName).group(keys, condition, initial, reduce, finalize, command, options);
|
|
134
|
+
async findOneAndUpdate(collectionName, filter, update, options) {
|
|
135
|
+
return this.getCollection(collectionName).findOneAndUpdate(filter, update, options || {});
|
|
148
136
|
}
|
|
149
137
|
/**
|
|
150
138
|
* Retrieve all the indexes on the collection.
|
|
151
139
|
*/
|
|
152
140
|
async collectionIndexes(collectionName) {
|
|
153
|
-
return
|
|
141
|
+
return this.getCollection(collectionName).indexes();
|
|
154
142
|
}
|
|
155
143
|
/**
|
|
156
144
|
* Retrieve all the indexes on the collection.
|
|
157
145
|
*/
|
|
158
146
|
async collectionIndexExists(collectionName, indexes) {
|
|
159
|
-
return
|
|
147
|
+
return this.getCollection(collectionName).indexExists(indexes);
|
|
160
148
|
}
|
|
161
149
|
/**
|
|
162
150
|
* Retrieves this collections index info.
|
|
163
151
|
*/
|
|
164
152
|
async collectionIndexInformation(collectionName, options) {
|
|
165
|
-
return
|
|
153
|
+
return this.getCollection(collectionName).indexInformation(options || {});
|
|
166
154
|
}
|
|
167
155
|
/**
|
|
168
156
|
* 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.
|
|
@@ -180,19 +168,19 @@ export class MongoQueryRunner {
|
|
|
180
168
|
* Inserts an array of documents into MongoDB.
|
|
181
169
|
*/
|
|
182
170
|
async insertMany(collectionName, docs, options) {
|
|
183
|
-
return
|
|
171
|
+
return this.getCollection(collectionName).insertMany(docs, options || {});
|
|
184
172
|
}
|
|
185
173
|
/**
|
|
186
174
|
* Inserts a single document into MongoDB.
|
|
187
175
|
*/
|
|
188
176
|
async insertOne(collectionName, doc, options) {
|
|
189
|
-
return
|
|
177
|
+
return this.getCollection(collectionName).insertOne(doc, options || {});
|
|
190
178
|
}
|
|
191
179
|
/**
|
|
192
180
|
* Returns if the collection is a capped collection.
|
|
193
181
|
*/
|
|
194
182
|
async isCapped(collectionName) {
|
|
195
|
-
return
|
|
183
|
+
return this.getCollection(collectionName).isCapped();
|
|
196
184
|
}
|
|
197
185
|
/**
|
|
198
186
|
* Get the list of all indexes information for the collection.
|
|
@@ -200,42 +188,23 @@ export class MongoQueryRunner {
|
|
|
200
188
|
listCollectionIndexes(collectionName, options) {
|
|
201
189
|
return this.getCollection(collectionName).listIndexes(options);
|
|
202
190
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
|
|
205
|
-
*/
|
|
206
|
-
async mapReduce(collectionName, map, reduce, options) {
|
|
207
|
-
return await this.getCollection(collectionName).mapReduce(map, reduce, options);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
|
|
211
|
-
* There are no ordering guarantees for returned results.
|
|
212
|
-
*/
|
|
213
|
-
async parallelCollectionScan(collectionName, options) {
|
|
214
|
-
return await this.getCollection(collectionName).parallelCollectionScan(options);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* 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.
|
|
218
|
-
*/
|
|
219
|
-
async reIndex(collectionName) {
|
|
220
|
-
return await this.getCollection(collectionName).reIndex();
|
|
221
|
-
}
|
|
222
191
|
/**
|
|
223
192
|
* 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.
|
|
224
193
|
*/
|
|
225
194
|
async rename(collectionName, newName, options) {
|
|
226
|
-
return
|
|
195
|
+
return this.getCollection(collectionName).rename(newName, options || {});
|
|
227
196
|
}
|
|
228
197
|
/**
|
|
229
198
|
* Replace a document on MongoDB.
|
|
230
199
|
*/
|
|
231
|
-
async replaceOne(collectionName,
|
|
232
|
-
return
|
|
200
|
+
async replaceOne(collectionName, filter, replacement, options) {
|
|
201
|
+
return this.getCollection(collectionName).replaceOne(filter, replacement, options || {});
|
|
233
202
|
}
|
|
234
203
|
/**
|
|
235
204
|
* Get all the collection statistics.
|
|
236
205
|
*/
|
|
237
206
|
async stats(collectionName, options) {
|
|
238
|
-
return
|
|
207
|
+
return this.getCollection(collectionName).stats(options || {});
|
|
239
208
|
}
|
|
240
209
|
/**
|
|
241
210
|
* Watching new changes as stream.
|
|
@@ -246,14 +215,14 @@ export class MongoQueryRunner {
|
|
|
246
215
|
/**
|
|
247
216
|
* Update multiple documents on MongoDB.
|
|
248
217
|
*/
|
|
249
|
-
async updateMany(collectionName,
|
|
250
|
-
return
|
|
218
|
+
async updateMany(collectionName, filter, update, options) {
|
|
219
|
+
return this.getCollection(collectionName).updateMany(filter, update, options || {});
|
|
251
220
|
}
|
|
252
221
|
/**
|
|
253
222
|
* Update a single document on MongoDB.
|
|
254
223
|
*/
|
|
255
|
-
async updateOne(collectionName,
|
|
256
|
-
return await this.getCollection(collectionName).updateOne(
|
|
224
|
+
async updateOne(collectionName, filter, update, options) {
|
|
225
|
+
return await this.getCollection(collectionName).updateOne(filter, update, options || {});
|
|
257
226
|
}
|
|
258
227
|
// -------------------------------------------------------------------------
|
|
259
228
|
// Public Implemented Methods (from QueryRunner)
|