E11000 duplicate key error collection i dont have unique field, help please

hi, i getting this error, i cant solve it.
so i have order model like this

import mongoose from "mongoose";

const OrderSchema = new mongoose.Schema(
  {
    userId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },
    products: [
      {
        productId: {
          type: mongoose.Schema.Types.ObjectId,
          ref: "Product", // Reference to the Product model
          required: true,
        },
        quantity: {
          type: Number,
          default: 1,
        },
      },
    ],
    amount: {
      type: Number,
      required: true,
    },
    address: {
      city: {
        type: String,
      },
      country: {
        type: String,
      },
      line1: {
        type: String,
      },
      line2: {
        type: String,
        default: null,
      },
      postal_code: {
        type: String,
      },
      state: {
        type: String,
        default: null,
      },
    },
    status: {
      type: String,
      default: "pending",
    },
  },
  { timestamps: true }
);

const Order = mongoose.model("Order", OrderSchema);

export default Order;

and product model as well

import mongoose from "mongoose";

const productSchema = new mongoose.Schema(
  {
    title: { type: String, required: true, unique: true },
    desc: { type: String, required: true },
    img: { type: String, required: true },
    categories: { type: Array },
    size: { type: Array },
    color: { type: Array },
    price: { type: Number, required: true },
    inStock: { type: Boolean, default: true },
  },
  { timestamps: true }
);
const Product = mongoose.model("Product", productSchema);

export default Product;

i am trying to make order with same userId value , it linked with user model, and grabbing id from there, but i dont have unique field in my order model, how can i avoid this error, help please
example of order in compas

i have different project where i used to have collection with same id like here


i have different project where i have collection with same id , and no error there

Despite the fact that you think that you do not have a unique field, If the server produces a duplicate key error the you must have a unique index. May be it was created before, may be it was created by somebody else. I am not familiar with Mongoose but I think that if the index already exists and a field goes from unique to non-unique, the index is not updated or removed.

The affirmation of not having a unique field seems to be contradicted by your schema:

This is why it would help is that you share the exact error message that you get, the offending index is part of the error message.

Sharing the user schema might also help.

Sharing the output of getIndexes() on all you collection will also provide a better understanding.

Thanks for you attention . i solved it , i remove cluster and create new one, i think cluster just stuck)

Not really. But by

you got rid of the

If the data was not important you could have simply drop the collection. And if the data was important just removing the index that is not updated or deleted automatically by mongoose. Not understanding what mongoose do or do not do with your index will cause more harm in the future. The following passage from mongoose documentation seems to be the key of your issue.

This means that indexes will only be ensured once during the lifetime of your app.