[Solved] Warning: creating anonymous collection. It will not be saved or synchronized over the network. (Pass null for the collection name to turn off this warning.)

Get error when insert doc

Warning: creating anonymous collection. It will not be saved or synchronized over the network. (Pass null for the collection name to turn off this warning.)

My Schema

export default new SimpleSchema({
  refNo: { // getNextSeq(...) function with Meteor.wrapAsync
    type: String,
  },
  name: {
    type: String,
  },
  memo: {
    type: String,
    optional: true,
  },
})

You will get this kind of warning when you define some database collection like this:
const SomeCollection = new Mongo.Collection();
To get rid of this warning, you add null as param:
const SomeCollection = new Mongo.Collection(null);
This collection will be available on client side only.

thanks for your reply.
Now I found the error on Constructor of Collection Extends

class BaseCollection extends Mongo.Collection {
  constructor() {
      super() // Maybe this error
  }
}
---
const MyCollection = new BaseCollection('test');

How to use contractor in extends collection?

Now it work fine

class BaseCollection extends Mongo.Collection {
  constructor(name) {
      super(name) // Maybe this error
  }
}
---
const MyCollection = new BaseCollection('test');
1 Like