Create and modify collections in a package

90 views Asked by At

I'm trying to create a collection within a package (technically within a build plugin):

StaticCollection = new Mongo.Collection(null)
// also the same with Mongo.Collection('static')
StaticCollection.insert({stuff: 'thing'})

But this throws essentially this error:

   While loading plugin `compileMarkdownFiles` from package `faichenshing:collection-files`:
   packages/compileMarkdownFiles/plugin/compile-md.js:29:1: Mongo is not defined
   at Package (packages/compileMarkdownFiles/plugin/compile-md.js:29:1)
   at <runJavaScript-268>:121:4
   at <runJavaScript-268>:128:3

This didn't work as Meteor.Collection either.

Then I tried to import the mongo collection into my build plugin like this:

Package.registerBuildPlugin({
  name: "compileMarkdownFiles",
  use: ['spacebars-compiler', 'mongo'],
  // etc.
});

as well as in my Package.onUse:

api.use('mongo')

it throws this error:

While loading plugin `compileMarkdownFiles` from package `faichenshing:collection-files`:
   packages/ddp/stream_server.js:3:1: __meteor_runtime_config__ is not defined
   at self (packages/ddp/stream_server.js:3:1)
   at <runJavaScript-83>:694:4
   at <runJavaScript-83>:4779:3

No amount of searching for __meteor_runtime_config__ has clarified this problem. It seems completely unrelated.

Questions like this one seem to not run into this problem at all.

The more I think about this the more convinced I am it has something to do with the existence of a build plugin in this code, but the collection definition isn't taking place within registerSourceHandler or anything.

0

There are 0 answers