Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

How to get an _id to UUID string after populate ? #20

@ystreibel

Description

@ystreibel

Hi,

I don't understand why is not possible to have an UUID String representation after a populate ?

This is the test code that I tried:

it('should work', function(cb) {
      Photo.findOne({_id: '7c401d91-3852-4818-985d-7e7b79f771c2'}).populate('pet').exec(function(err, photo) {
        (photo.pet).should.exist;
        (photo.pet.name).should.equal('Sammy');

        var photoJSON = photo.toJSON();

        cb(err);
      });
    });

And the error:

TypeError: photo.toJSON is not a function
    at /Users/username/Projects/mongoose-uuid/test/index.js:168:33
    at /Users/username/Projects/mongoose-uuid/node_modules/mongoose/lib/model.js:4759:16
    at /Users/username/Projects/mongoose-uuid/node_modules/mongoose/lib/utils.js:263:16
    at _hooks.execPost (node_modules/mongoose/lib/query.js:4074:11)
    at /Users/username/Projects/mongoose-uuid/node_modules/kareem/index.js:135:16
    at processTicksAndRejections (internal/process/next_tick.js:74:9)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions