Closed RafaelVidaurre closed 7 years ago
You're overriding the default Mongo.Collection
constructor but not accepting the same constructor parameters. Internally StubCollections
makes a call like this on your Accounts
collection:
const pair = {
localCollection: new collection.constructor(null, options),
collection,
};
It's trying to pass null
into your constructor, which would create the needed local collection, but your constructor is ignoring the passing in null
parameter (and trying to instantiate another accounts
collection). I would recommend changing your constructor
around to something like:
constructor(name, options) {
const collectionName = name || 'accounts';
const accounts = super(collectionName, {
transform(doc) {
return new Account(doc);
},
});
...
Thanks a bunch I'll try that!
I'm trying to stub a collection that comes from a package, it is defined like this:
Account model has:
On the Client I'm trying to stub like this:
I'm getting
Uncaught Error: There is already a collection named "accounts"