Skip to content

Problem with mongoose model serialization #149

Closed
@jselesan

Description

@jselesan

Hi!. I'm using routing-controllers with mongoose, but when my controller returns the result of a query, the _id field of the models are serialized as

{"_id":{"_bsontype":"ObjectID","id":{"0":89,"1":17,"2":175,"3":60,"4":137,"5":110,"6":193,"7":50,"8":29,"9":2,"10":180,"11":121}}

My method is:

@Get("/")
  all() {
      return this.usersService.getAll().then( users => users.map(u => u.toJSON()) );
  }

I think that the problem is the class transformer, but I don't know how to fix it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions