I planned to insert my code by MongoDB compass but when I clicked 'Insert' button, it only appears 'Inserting Document' but nothing happened even after I clicked the 'Insert' button many times and after that I try to refresh my MongoDB compass but nothing happened and the data is not inserted.
Here's my code:
{
"_id": "7",
"listing_id": "677728659232692395",
"arrival_date": new ISODate("2022-11-08T14:10:30Z"),
"departure_date": new ISODate("2022-11-15T14:10:30Z"),
"name": { first_name: "Gregorius", last_name: "Agung"
},
"email": "[email protected]",
"contact": {
"daytime_phone": "0921970278",
"mobile": "0917820292",
"postal_address": {
"door": "5",
"floor": "12",
"street": "Swanston",
"suburb": "Weribee",
"state": "Victoria",
"country": "Australia",
"postal_code": "3003"
}, home_address: {
"door": "4",
"floor": "11",
"street": "Swanston",
"suburb": "Weribee",
"state": "Victoria",
"country": "Australia",
"postal_code": "3003"
}
},
"number_of_guests": 2,
"guests": [
{
"name": "Marvel",
"age": 22
},
{
"name": "Bryant",
"age": 23
}
],
"deposit_paid": {$numberDecimal: 120.01
},
"balance_due_amount": {$numberDecimal: 120.01
},
"balance_due_date": new ISODate(
"2022-11-08T14:10:30Z")
}
CodePudding user response:
It seems your json is wrong. Some of the keys are not in quotes and for date insertion this is not working in compass.
I tried this and it is working
{
"_id": "7",
"listing_id": "677728659232692395",
"arrival_date": {
"$date": {
"$numberLong": "1667916630000"
}
},
"departure_date": {
"$date": {
"$numberLong": "1668521430000"
}
},
"name": {
"first_name": "Gregorius",
"last_name": "Agung"
},
"email": "[email protected]",
"contact": {
"daytime_phone": "0921970278",
"mobile": "0917820292",
"postal_address": {
"door": "5",
"floor": "12",
"street": "Swanston",
"suburb": "Weribee",
"state": "Victoria",
"country": "Australia",
"postal_code": "3003"
},
"home_address": {
"door": "4",
"floor": "11",
"street": "Swanston",
"suburb": "Weribee",
"state": "Victoria",
"country": "Australia",
"postal_code": "3003"
}
},
"number_of_guests": 2,
"guests": [
{
"name": "Marvel",
"age": 22
},
{
"name": "Bryant",
"age": 23
}
],
"deposit_paid": {
"$numberDecimal": "120.01"
},
"balance_due_amount": {
"$numberDecimal": "120.01"
},
"balance_due_date": {
"$date": {
"$numberLong": "1667916630000"
}
}
}