Data Types
{audience_rating: 6}
{audience_rating: 7.6}
{"title": "A Swedish Love Story", released: "1970-04-24"}
{"title": "A Swedish Love Story", released: "24-04-1970"}
{"title": "A Swedish Love Story", released: "24th April 1970"}
{"title": "A Swedish Love Story", released: "Fri, 24 Apr 1970"}
var name="Rachel Green"
name
var plainNum = 1299
plainNum
// forces MongoDB to use 32 bit
var explicitInt = NumberInt("1299")
explicitInt
// long forces 64 bit
var explicitLong = NumberLong("777888222116643")
explicitLong
var explicitLong_double = NumberLong(444333222111242)
explicitLong_double
// forces 128 bit
var explicitDecimal = NumberDecimal("142.42")
explicitDecimal
var explicitDecimal_double = NumberDecimal(142.42)
explicitDecimal_double
//values are rounded off
var decDbl = NumberDecimal(5999999999.99999999)
decDbl
// boolean demo
var isActive=true
isActive
var isDeleted=false
isDeleted
// objects
var friend={
"first_name":"Rachel",
"last_name":"Green",
"email":"rachel@friends.com"
}
friend
friend.first_name
var friends1=[
{
"firstname": "Phoebe",
"lastname":"Buffay",
"age": 31,
"profession":"Therapist"
},
{
"firstname": "Ross",
"lastname":"Geller",
"age": 31,
"location": "NY",
"profession":"Palentologist",
"spouses":["Carol","Emily","Rachel"]
},
{
"firstname": "Chandler",
"lastname":"Bing",
"age": 31,
"location": "NY"
},
{
"firstname": "Joey",
"lastname":" Tribianni",
"age": 32,
"location": "NYC",
"profession":"actor"
}
]
var friends2 = [
{
"firstname": "rachel",
"lastname" : "green",
"age" : 30,
"location": "NYC",
"profession":"Fashion Designer"
},
{
"name":{"firstname":"Ben",
"lastname" : "Geller"},
"age" : 6,
"location": "NYC"
},
{
"name":{"firstname":"Emma",
"lastname" : "Geller"},
"age" : 1,
"location": "NYC"
}
]
Array Slice
Last updated