scottwrobinson / camo

A class-based ES6 ODM for Mongo-like databases.
556 stars 80 forks source link

null _id for EmbeddedDocuments #31

Closed ijsf closed 8 years ago

ijsf commented 8 years ago

Quick bug post.

Whenever an Document is returned that contains an EmbeddedDocument, the object that represents the EmbeddedDocument always contains an element _id that is set to null.

It is obviously set to null because EmbeddedDocument's do not have id's, however the _id shouldn't be defined at all.

class Embedded extends camo.EmbeddedDocument
{
  constructor()
  {
    super();
    this.whatever = String;
  }
}
class ABC extends camo.Document
{
  constructor()
  {
    super();
    this.a =  { type: Embedded, required: false };
  }
}

Whenever ABC is returned, a will always be defined and contain a _id set to null.

scottwrobinson commented 8 years ago

Thanks for pointing this out! A fix is on its way.