You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/databases/mongodb.md
+19-83Lines changed: 19 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -394,101 +394,37 @@ For more information on MongoDB's collation feature, visit the [collation refere
394
394
395
395
MongoDB uses [ObjectId](https://www.mongodb.com/docs/manual/reference/method/ObjectId/) object as primary keys. To store them in the right format they have to be converted from and to strings.
396
396
397
-
### AJV format
397
+
### AJV keyword
398
398
399
-
To validate an ObjectId via the `format`keyword, add the following to your `validators` file:
399
+
To validate and convert strings to an object id using AJV, the `keywordObjectId`[AJV keyword](https://ajv.js.org/api.html#ajv-addkeyword-definition-string-object-ajv) helper can be used. It is set up automatically in a generated application using MongoDB.
Usually a converted object id property can be treated like a string but in some cases when working with it on the server you may have to call `toString()` to get the proper type.
When choosing MongoDB, the validators file will also register the [`objectid` keyword](../../api/databases/mongodb.md#ajv-keyword) to convert strings to MongoDB Object ids.
0 commit comments