Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am in a real trouble now !

I have a Json file like below :

{ \"_id\" : ObjectId(\"59b24213d772ea41bc44e017\"), 

\"values\" :
 [
{ \"ProductName\" : \"BH0001  \"QuantityOnHand\" : 55579.0 }, 
{ \"ProductName\" : \"BH0101 \", \"QuantityOnHand\" : 15741.0 }, 
{ \"ProductName\" : \"BH0102 \", \"QuantityOnHand\" : -802.0 }
]
}


How to get the Quantities by sending productName as keyword ?

For example I need to write a query like select QuantityOnHand from this document where productName =BH001

What I have tried:

db.Mycollections.find({'values.ProductName':'BH0001')})
I used like this , but its showing all the values just like simple find query ! :(
Posted
Updated 11-Sep-17 2:21am
v2
Comments
Richard MacCutchan 8-Sep-17 12:14pm    
And what happens when you try it?
ali_1 11-Sep-17 8:23am    
db.Mycollections.find({'values.ProductName':'BH0001')})

I tried this but not working Richard!
I am converting the datatable and inserting into mongodb using collection.insertone statement !.. Do i need to use insertMany instead of insertone ?
Richard MacCutchan 11-Sep-17 11:14am    
Sorry, I do not understand what you are trying to say.
ali_1 12-Sep-17 7:24am    
Simply tell me how to get the Quantity for BH0001
Richard MacCutchan 12-Sep-17 10:43am    
How can I when I have no idea what your database table structure is?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900