title: TypeError: this.$__setSchema is not a function
body: <p>I am trying to insert data into mongodb at <a href="https://cloud.mongodb.com/" rel="nofollow noreferrer">mongodb cloud</a>. But while running the code i am getting error like TypeError: this.$__setSchema is not a function.</p>
  <p><img src="https://i.stack.imgur.com/a8LWt.png" alt="" /></p>
  <pre><code>//Function Called
  
  this.$__setSchema(_schema);
  
  //Function Definition
  
  Document.prototype.$__setSchema = function(schema) {
  
      schema.plugin(idGetter, { deduplicate: true });
      compile(schema.tree, this, undefined, schema.options);
  
      // Apply default getters if virtual doesn't have any (gh-6262)
      for (const key of Object.keys(schema.virtuals)) {
          schema.virtuals[key]._applyDefaultGetters();
      }
      if (schema.path('schema') == null) {
          this.schema = schema;
      }
      this.$__schema = schema;
      this[documentSchemaSymbol] = schema;
  };
  </code></pre>