I am creating a collection blog with the following unique index:
{
"title" : 1,
"author" : 1
}
unique:true
This collection consists the following document
{
"title":"Java",
"author":"ABC",
code:123
}
Now I want to insert the following document into it
[{
"title":"JAVA",
"author":"ABC",
code:234
}]
I am using insertMany query to add this to the collection. but the collection has a unique index. so when I try to insert the above document in the collection it will give an error like the title is not unique. but I want check other field error also here so I am using insertMany query with ordered option like:
db.insertMany("blog",[{
"title":"JAVA",
"author":"ABC",
code:234
}]
, {ordered: false})
the above query error gives me all two field names. but when I am trying to use this with Mongodb transaction it will gives only one field error I am using Transaction like:
let session = await db.startSession({});
db.insertMany("blog",[{
"title":"JAVA",
"author":"ABC",
code:234
}]
, {ordered: false, session})
SO how I get all fields name in result whose no unique using insertMany, ordered, and session? Kindly help me here