Skip to content

Mongoose 5.13.8 troubles #56

@Able1991

Description

@Able1991

Hello there.
Not work implementation from examples with MUUID.from(this._id).toString();
this._id - is mongo lib object
Now if fix with

_id: {
  type: Buffer,
  subtype: 4,
  default: () => MUUID.v1(),
},

....

// virtual getter for custom _id
schema
  .virtual("id")
  .get(function () {
    return MUUID.from(this._id.toBSON()).toString();
  })
  .set(function (val) {
    this._id = MUUID.from(val);
  });

Is this a normal solution, or is it necessary to do something else?

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