I'm developing a test frameword where I want to reset all collections on each run.
I'm having problems doing this with Meteor.users
, since it's undefined on the package environment.
Is there any workaround to clean the Meteor.users collection from within a package?
The package load order and exported variables matter when it comes to symbol availability in packages.
In order to get a symbol created in a package, it has to be loaded prior to your package. This can be achieved by depending on it or on some other package that depends on it.
Examples of such symbols are methods added to the
Meteor
object, and this is what is happening in your case.In order to get a symbol that is exported by a package, you should either directly depend on it, or depend on a package that implies this package (or explicitly exports the symbol on its own as well).
You can make this dependency weak if you don't want the package to be added to the bundle if your package is the only one that depends on it (i.e, there are no other packages that strongly depend on it, and the user did not add it as a top-level dependency).
If you need to do something after all of the packages have loaded, you can do so with
Meteor.startup()
: