mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Specifically, Mongo.Collection objects on the server now have rawCollection and rawDatabase methods. You can use MongoInternals.NpmModules.mongodb.version to tell what version of the mongodb npm module is the backend for HTTP.call. This version may change incompatibly from version to version of Meteor; use at your own risk. (For example, we expect to upgrade from the 1.4.x series to the 2.x series in the not-too-distant future.) Fixes #3640.
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
MongoInternals.RemoteCollectionDriver = function (
|
|
mongo_url, options) {
|
|
var self = this;
|
|
self.mongo = new MongoConnection(mongo_url, options);
|
|
};
|
|
|
|
_.extend(MongoInternals.RemoteCollectionDriver.prototype, {
|
|
open: function (name) {
|
|
var self = this;
|
|
var ret = {};
|
|
_.each(
|
|
['find', 'findOne', 'insert', 'update', 'upsert',
|
|
'remove', '_ensureIndex', '_dropIndex', '_createCappedCollection',
|
|
'dropCollection', 'rawCollection'],
|
|
function (m) {
|
|
ret[m] = _.bind(self.mongo[m], self.mongo, name);
|
|
});
|
|
return ret;
|
|
}
|
|
});
|
|
|
|
|
|
// Create the singleton RemoteCollectionDriver only on demand, so we
|
|
// only require Mongo configuration if it's actually used (eg, not if
|
|
// you're only trying to receive data from a remote DDP server.)
|
|
MongoInternals.defaultRemoteCollectionDriver = _.once(function () {
|
|
var connectionOptions = {};
|
|
|
|
var mongoUrl = process.env.MONGO_URL;
|
|
|
|
if (process.env.MONGO_OPLOG_URL) {
|
|
connectionOptions.oplogUrl = process.env.MONGO_OPLOG_URL;
|
|
}
|
|
|
|
if (! mongoUrl)
|
|
throw new Error("MONGO_URL must be set in environment");
|
|
|
|
return new MongoInternals.RemoteCollectionDriver(mongoUrl, connectionOptions);
|
|
});
|