_createIndex => createIndex

and other fixes from PR
This commit is contained in:
Jan Dvorak
2021-07-28 15:53:42 +02:00
parent 77170310eb
commit 8a476251be
6 changed files with 21 additions and 13 deletions

View File

@@ -5,6 +5,9 @@
* `meteor-tool@2.4`
- `meteor show` now reports if a package is deprecated
* `mongo@1.13.0`
- Add `createIndex` as a collection function. This is a new name for `_ensureIndex` which MongoDB has deprecated and removed in MongoDB 5.0. Use of `_ensureIndex` will show a deprecation warning on development.
#### Independent Releases
* `minifier-js@2.6.1`
@@ -20,9 +23,6 @@
- Modernized the code
- Fixed a variable assignment bug in `dontBindEnvironment` function
* `mongo@1.12.1`
- Add `_createIndex` as a collection function. This is a new name for `_ensureIndex` which MongoDB has deprecated and removed in MongoDB 5.0.
## v2.3.2, 2021-07-13
#### Meteor Version Release

View File

@@ -671,14 +671,21 @@ Object.assign(Mongo.Collection.prototype, {
var self = this;
if (!self._collection._ensureIndex)
throw new Error("Can only call _ensureIndex on server collections");
self._collection._ensureIndex(index, options);
if (self._collection.createIndex) {
import { Log } from 'logging';
Log.debug('_ensureIndex has been deprecated, please use the new `createIndex` instead')
self._collection.createIndex(index, options);
} else {
self._collection._ensureIndex(index, options);
}
},
_createIndex(index, options) {
createIndex(index, options) {
var self = this;
if (!self._collection._createIndex)
throw new Error("Can only call _createIndex on server collections");
self._collection._createIndex(index, options);
if (!self._collection.createIndex)
throw new Error("Can only call createIndex on server collections");
self._collection.createIndex(index, options);
},
_dropIndex(index) {

View File

@@ -829,7 +829,7 @@ MongoConnection.prototype.findOne = function (collection_name, selector,
// We'll actually design an index API later. For now, we just pass through to
// Mongo's, but make it synchronous.
MongoConnection.prototype._createIndex = function (collectionName, index,
MongoConnection.prototype.createIndex = function (collectionName, index,
options) {
var self = this;
@@ -841,7 +841,7 @@ MongoConnection.prototype._createIndex = function (collectionName, index,
future.wait();
};
MongoConnection.prototype._ensureIndex = MongoConnection.prototype._createIndex;
MongoConnection.prototype._ensureIndex = MongoConnection.prototype.createIndex;
MongoConnection.prototype._dropIndex = function (collectionName, index) {
var self = this;

View File

@@ -59,7 +59,7 @@ process.env.MONGO_OPLOG_URL && testAsyncMulti(
var self = this;
self.collectionName = Random.id();
self.collection = new Mongo.Collection(self.collectionName);
self.collection._createIndex({species: 1});
self.collection.createIndex({species: 1});
// Fill collection with lots of irrelevant objects (red cats) and some
// relevant ones (blue dogs).

View File

@@ -9,7 +9,7 @@
Package.describe({
summary: "Adaptor for using MongoDB and Minimongo over DDP",
version: '1.12.0'
version: '1.12.0-beta240.2'
});
Npm.depends({
@@ -35,6 +35,7 @@ Package.onUse(function (api) {
'check',
'ecmascript',
'mongo-dev-server',
'logging'
]);
// Make weak use of Decimal type on client

View File

@@ -9,7 +9,7 @@ Object.assign(MongoInternals.RemoteCollectionDriver.prototype, {
var self = this;
var ret = {};
['find', 'findOne', 'insert', 'update', 'upsert',
'remove', '_ensureIndex', '_createIndex', '_dropIndex', '_createCappedCollection',
'remove', '_ensureIndex', 'createIndex', '_dropIndex', '_createCappedCollection',
'dropCollection', 'rawCollection'].forEach(
function (m) {
ret[m] = _.bind(self.mongo[m], self.mongo, name);