mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Convert Mongo.Collection to class and remove underscore on client.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,9 @@
|
||||
Tinytest.add(
|
||||
'collection - call Mongo.Collection without new',
|
||||
function (test) {
|
||||
test.throws(
|
||||
function () {
|
||||
Mongo.Collection(null);
|
||||
},
|
||||
/use "new" to construct a Mongo\.Collection/
|
||||
);
|
||||
test.throws(function () {
|
||||
Mongo.Collection(null);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
LocalCollectionDriver = function () {
|
||||
var self = this;
|
||||
self.noConnCollections = {};
|
||||
};
|
||||
// singleton
|
||||
export const LocalCollectionDriver = new (class LocalCollectionDriver {
|
||||
constructor() {
|
||||
this.noConnCollections = Object.create(null);
|
||||
}
|
||||
|
||||
var ensureCollection = function (name, collections) {
|
||||
if (!(name in collections))
|
||||
collections[name] = new LocalCollection(name);
|
||||
return collections[name];
|
||||
};
|
||||
|
||||
_.extend(LocalCollectionDriver.prototype, {
|
||||
open: function (name, conn) {
|
||||
var self = this;
|
||||
if (!name)
|
||||
open(name, conn) {
|
||||
if (! name) {
|
||||
return new LocalCollection;
|
||||
if (! conn) {
|
||||
return ensureCollection(name, self.noConnCollections);
|
||||
}
|
||||
if (! conn._mongo_livedata_collections)
|
||||
conn._mongo_livedata_collections = {};
|
||||
|
||||
if (! conn) {
|
||||
return ensureCollection(name, this.noConnCollections);
|
||||
}
|
||||
|
||||
if (! conn._mongo_livedata_collections) {
|
||||
conn._mongo_livedata_collections = Object.create(null);
|
||||
}
|
||||
|
||||
// XXX is there a way to keep track of a connection's collections without
|
||||
// dangling it off the connection object?
|
||||
return ensureCollection(name, conn._mongo_livedata_collections);
|
||||
}
|
||||
});
|
||||
|
||||
// singleton
|
||||
LocalCollectionDriver = new LocalCollectionDriver;
|
||||
function ensureCollection(name, collections) {
|
||||
return (name in collections)
|
||||
? collections[name]
|
||||
: collections[name] = new LocalCollection(name);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ Package.onUse(function (api) {
|
||||
api.use([
|
||||
'random',
|
||||
'ejson',
|
||||
'underscore',
|
||||
'minimongo',
|
||||
'ddp',
|
||||
'tracker',
|
||||
@@ -38,6 +37,8 @@ Package.onUse(function (api) {
|
||||
'mongo-dev-server',
|
||||
]);
|
||||
|
||||
api.use('underscore', 'server');
|
||||
|
||||
// Binary Heap data structure is used to optimize oplog observe driver
|
||||
// performance.
|
||||
api.use('binary-heap', 'server');
|
||||
|
||||
Reference in New Issue
Block a user