I am wondering how I can check if an entry exists in mongodb. example :
I have this schema :
const AuthorSchema = new Schema({
name : { type : String, required : true},
books: [BookSchema]
});
If the Author i am trying to add already exists I would like to still add the book to the existing author , but I dont want to create a duplicate of author.
Pseudo code is fine, as long as I get the Idea of the flow. Any posts or blog articles are fine as long as they describe the problem i am having.