Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

that.collectionName is not a function on EmbeddedDocument #26

Closed
ijsf opened this issue Dec 29, 2015 · 2 comments
Closed

that.collectionName is not a function on EmbeddedDocument #26

ijsf opened this issue Dec 29, 2015 · 2 comments
Labels

Comments

@ijsf
Copy link

ijsf commented Dec 29, 2015

I am having an issue when trying to create (and save) an EmbeddedDocument. I have the following class:

class Reminder extends camo.EmbeddedDocument
{
  constructor()
  {
    super();
    this.enabled = { type: Boolean, required: true };
  }
}

Now, when I create a Reminder instance that does not adhere to the above, e.g. the enabled property is missing, like in this example:

Reminder.create({}).save();

I get the following error:

info: TypeError: that.collectionName is not a function

This is obviously an artifact of the new collectionName functionality in the validate function inside camo. Except, collectionName does not exist in EmbeddedDocument instances.

Probably quite an easy fix.

@scottwrobinson
Copy link
Owner

Yup, you're right. Dumb mistake, but an easy fix.

Also, just to be clear, make sure you're calling save() on the Document and not EmbeddedDocument object.

Should have the fix out soon with the rest of the bugs I'm working on. Thanks for pointing this out!

@CKarper
Copy link

CKarper commented Jan 5, 2016

+1

bvkimball pushed a commit to bvkimball/crypsis that referenced this issue Jan 15, 2016
* upstream/master: (41 commits)
  Bumped version, updated CHANGELOG, and updated README
  Fixed serialization test for MongoDB IDs
  Deprecated 'id' alias on document object for issue scottwrobinson#20
  Removing some inconsistencies with accessing the ID. Partially covers issue scottwrobinson#20
  Consolidated hook code so it can be re-used throughout Document methods
  Moved collectionName method to BaseDocument. Fixes scottwrobinson#26
  Added new ValidationError object, fixed some validation tests, fixed min/max validation, and fixed validation for array of embedded documents
  Fixed issue with running 'canonicalize' tests on travis-ci and bumped version
  Removed unused harmony-reflect dependency, updated CHANGELOG, and bumped version
  Updated CHANGELOG, README, and bumped version
  Removed --harmony-proxies flag from tests now that Proxy isn't used
  Added sanity check to 'required' tests
  Updated PR scottwrobinson#19 to conform to new collection naming
  Changed how you name collections
  Removed need for Proxy and harmony-reflect dependency
  Added a required key value validation.
  Adding .npmignore file
  Moved jshint settings out of package.json and in to .jshintrc file. Updated .gitignore for .jshintrc
  Removed custom harmony-reflect script and adding harmony-reflect as dependency
  Added tests for canonicalizing dates
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants