New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document a way to access the Node Mongo driver #3640

Closed
theduke opened this Issue Feb 4, 2015 · 8 comments

Comments

Projects
None yet
4 participants
@theduke

theduke commented Feb 4, 2015

Is there any way to lock the database on the server?

In mongo I would call db.fsyncLock().

@glasser glasser added this to the Winter 2015 Mongo Maintenance milestone Feb 10, 2015

@glasser glasser changed the title from Support request - Mongo fsyncLock to Document a way to access the Node Mongo driver Feb 10, 2015

@glasser

This comment has been minimized.

Member

glasser commented Feb 10, 2015

Thanks for the feature request! You might be interested in reading our feature request guidelines.

This is a subset of a frequently requested feature, which is direct access to all the various Mongo APIs that don't have special Meteor behavior. I think we should actually do this finally.

We should provide access to:

  • The raw Node Mongo driver module
  • Its version number
  • A simple wrapper or two to get you the db object for a given Meteor Mongo connection, and maybe a Collection

That said, people using this should be aware that future upgrades may replace the module with a backward-incompatible version. (This would probably be a major version bump for the mongo package.)

glasser added a commit that referenced this issue Mar 5, 2015

glasser added a commit that referenced this issue Mar 5, 2015

mongo: provide direct access to node driver db
Specifically, Mongo.Collection objects on the server now have
getNativeCollection and getNativeDB 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.

glasser added a commit that referenced this issue Mar 5, 2015

mongo: provide direct access to node driver db
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.

glasser added a commit that referenced this issue Mar 5, 2015

glasser added a commit that referenced this issue Mar 5, 2015

mongo: provide direct access to node driver db
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.
@mitar

This comment has been minimized.

Collaborator

mitar commented Mar 5, 2015

https://github.com/peerlibrary/meteor-directcollection provides you with a way to send arbitrary commands through the Meteor Mongo connection.

@mitar

This comment has been minimized.

Collaborator

mitar commented Mar 5, 2015

(Do observe that methods which are provided by directcollection are blocking, so it is not just exposing the API, but also making sure that it plays nice with Meteor.)

@glasser

This comment has been minimized.

Member

glasser commented Mar 5, 2015

Great; it looks like you should now be able to use these new documented APIs in implementing your package.

glasser added a commit that referenced this issue Mar 6, 2015

@glasser glasser closed this in 63a0076 Mar 6, 2015

@theduke

This comment has been minimized.

theduke commented Mar 21, 2015

Greath, thank you guys.

@zstew

This comment has been minimized.

zstew commented Jun 4, 2015

Do I understand that the resolution is to use https://github.com/peerlibrary/meteor-directcollection
to access the mongo connection?

I'm really hoping to be able to write something like:
var myLongedForMongoConnection = Meteor.getMongoConnection();

this would be super useful to me. The above library seams to expect fibers style code, and I've got a lot of code I'd like to reuse that uses callbacks.

@glasser

This comment has been minimized.

Member

glasser commented Jun 4, 2015

No, I was referring to the rawCollection and rawDatabase methods on Mongo.Collection, added in 1.0.4. You're probably looking for var myLongedForMongoConnection = someCollection.rawDatabase().

@zstew

This comment has been minimized.

zstew commented Jun 4, 2015

yes! that's what I'm looking for! Thanks glasser! I'm reading up on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment