Skip to content

Commit 04f79c0

Browse files
authored
Update json-schema-validation.adoc
Specify how to use bson types in json schemas
1 parent 19b333d commit 04f79c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/mongodb-rest/json-schema-validation.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ The collection metadata's `jsonSchema` property has the following options:
281281

282282
MongoDB uses BSON (Binary JSON) which supports additional data types not available in standard JSON. To validate these types, you can define schema definitions for BSON types.
283283

284+
Note: Prefix Bson types with an underscore to prevent the request parser from interpreting them as actual Bson types, e.g., use _$date instead of $date.
285+
284286
==== Example: Defining BSON Types Schema
285287

286288
==== cURL
@@ -296,14 +298,14 @@ curl -i -X PUT "[RESTHEART-URL]/_schemas/bson" \
296298
"date": {
297299
"type": "object",
298300
"properties": {
299-
"$date": { "type": "number" }
301+
"_$date": { "type": "number" }
300302
},
301303
"additionalProperties": false
302304
},
303305
"objectid": {
304306
"type": "object",
305307
"properties": {
306-
"$oid": { "type": "string" }
308+
"_$oid": { "type": "string" }
307309
},
308310
"additionalProperties": false
309311
}

0 commit comments

Comments
 (0)