vendredi 1 juin 2018

mongo db how to use cursor function to find a condition with if statement?

Hi guys I have created a cursor in mongo db to find a condition which is shown below

var mycursor = db.catalog.find({})
mycursor.forEach(function(x)
    {if(x.book.find({"publisher":{"$exists":true ,"$ne" : ""}}) 
        {print("Publisher","Empty", " publishes book ", 
            x.book.title, "published at", x.book.publish_date)}})

What i want my function to do is find all publishers whose value is " " and then print the values respectively I know my if statement is incorrect I am just confused as to how i would write one for this case if anyone can point me to the right direction I will be grateful

Aucun commentaire:

Enregistrer un commentaire