I'm trying to add boolean status
field to a document on MongoLabs but I get a syntax error on that particular field when I try to save.
The type specifier seems 8
sees good according to the docs, but I can't find any examples on defining a boolean field within a document.
I managed to pin down the error to the status field, as the document saves without this field added.
Can anyone advise on the correct BSON syntax for the boolean field?
This is the boolean field I've added:
"status": {
{"$type": 8 } : true
}
And the complete document for reference:
{
"_id": {
"$oid": "565c4a37e4b0ed4652848949"
},
"email": "jd@outlook.com",
"products": [
{
"productId": "0121",
"price": 12.5,
"description": "A generic muffin"
},
{
"productId": "0122",
"price": 13.5,
"description": "A generic coffee"
},
{
"productId": "0123",
"price": 14.5,
"description": "A generic tea"
}
],
"date": {
"$date": "2014-03-03T03:45:00.000Z"
},
"status": {
{"$type": 8 } : true
}
}
In case anyone else had the same issue. The data stored on MongoLabs is JSON, which is then converted to BSON locally using the driver.
The correct format below is as follows:
{
"status": true
}