$Ceil is the function that is used to round a double to floor or ceiling. $ceil comes under the mongo aggregate function, below is the example Mongo statement to retrieve data based on ceiling
Let’s assume below is the cloths collection.
{"_id" : 110, "Price" : 10.35 }
{"_id" : 120, "Price" : 17.83 }
{"_id" : 130, "Price" : 16.52 }
{"_id" : 140, "Price" : -99.54}
db.cloths.aggregate([{
$project:"beforeRound":"$Price","roundedvalue":$ceil:"$Price"}}
}])
Output for cloths collection and above Statement is:
{ "_id" : 110, "beforeRound" : 10.35, "roundedvalue" : 11 }
{ "_id" : 120, "beforeRound" : 17.83, "roundedvalue" : 18 }
{ "_id" : 130, "beforeRound" : 16.52, "roundedvalue" : 17 }
{ "_id" : 140, "beforeRound" : -99.54, "roundedvalue" : -99 }
{ "_id" : 140, "beforeRound" : -99.54, "roundedvalue" : -99 }
$ceil is used to round the decimal values.
$project is used to retrieve
the specific columns from collection.
$price is used to project the
price value from the mongo node.
1 Comments
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.
ReplyDeletecloud computing course in Hyderabad