'MongoDB: create() is duplicate document with indexed id?
I have a syntax MongoDB create() function below:
const create = async (info, opts = {}) => {
const data = await Model.create(info, opts);
return data;
};
And when I pass that info argument with object type {} and MongoDB will create 1 more document:

I tried to pass this info argument with the following syntax: [{}] ==> The problem is solved. But I still cant understand why ??? Could someone please tell me the reason for this problems. Many thanks!!!
This is my Schema definition:
const MarketOrder = new Schema ({
id: { type: String, default: uuidV4, unique: true, index: true },
buyer: {type: String},
seller: {type: String},
type: { type: String, enum: ["NFT"] },
object: { type: String, refPath: "objectModel" },
objectModel: {
type: String,
//required: true,
enum: [
"market.nft",
//"user.nft.sets",
//"market.creator",
],
},
number: {type: Number},
price: {type: Number},
collectionAddrs: [{type: String}],
tokenIds: [{type: String}],
marketSig: {type: String},
txHash: {type: String},
status: {type: String}
},
{
timestampe: true
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
