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

Allow custom _id #29

Closed
dcsan opened this issue Jan 4, 2016 · 1 comment
Closed

Allow custom _id #29

dcsan opened this issue Jan 4, 2016 · 1 comment

Comments

@dcsan
Copy link

dcsan commented Jan 4, 2016

I'm using meteorJS which does some odd things with the _id field for mongo records.
I want to use plain strings as _id s with Camo to avoid this type of mix/match when writing from a raw node app with camo:

image

I tried overriding the _id field in a document, but that didn't work. Is this something that can be done?

var Document = require('camo').Document;

class Lessons extends Document {
  constructor() {
    super('Lessons');
    this._id = 'id' + Math.random;
    this.cname = String;
    this.rive = String;
  }

  static collectionName() {
    return 'Lessons';
  }

}

info:
http://stackoverflow.com/questions/15318184/meteor-collection-objectid-vs-mongodb-objectid

@scottwrobinson scottwrobinson changed the title using own _id field? Allow custom _id Jan 5, 2016
@scottwrobinson
Copy link
Owner

As of right now Camo does not allow you to provide your own custom _id. Looks like both Mongo and NeDB support this, so I'll add it to Camo as well. Just make sure you conform to the id requirements of whichever database you're using (unique, 16 or 24 characters long, etc).

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants