How to rename _id to id

Hello, MongoDB communities,
I have a model code as follows:

const CartSchema = new Schema({
    userId: {
      type: String,
      required: true
    products: [
        productId: {
          type: String
        quantity  : {
          type: Number,
          default: 1
  timestamps: true,
  versionKey: false,
  id: true,
  toJSON: {
    transform(doc, ret){ = ret._id
      delete ret._id

when I perform a request to save a cart I see _id in the products array.
I follow a discussion on stack overflow where they address to make _id: false.

Stop Mongoose from creating _id property for sub-document array items

How can I receive id instead of _id in the products array without an error message like:

document must have an _id before saving