Hi, I'm trying to use the library to insert a new document that has a UUID as id in my collection. I would like this collection to have a validation schema to make sure that every ids of the documents inserted are UUIDs. However, when I'm specifying the BSON type 'object', the validation won't pass.
I have seen in the examples that I could use mongoose, but I would prefer the validation to be perform at the database level. Do you have any idea of how I could make this work or any explanation of why it is not working? Thank you!
ERROR: Could not migrate up 20210627041314-create-categories.js: Document failed validation BulkWriteError: Document failed validation
at OrderedBulkOperation.handleWriteError (C:\Users\username\projectDirectory\node_modules\mongodb\lib\bulk\common.js:1352:9)
at resultHandler (C:\Users\username\projectDirectory\node_modules\mongodb\lib\bulk\common.js:579:23)
at handler (C:\Users\username\projectDirectory\node_modules\mongodb\lib\core\sdam\topology.js:943:24)
at C:\Users\username\projectDirectory\node_modules\mongodb\lib\cmap\connection_pool.js:350:13
at handleOperationResult (C:\Users\username\projectDirectory\node_modules\mongodb\lib\core\sdam\server.js:558:5)
at MessageStream.messageHandler (C:\Users\username\projectDirectory\node_modules\mongodb\lib\cmap\connection.js:281:5)
at MessageStream.emit (events.js:321:20)
at processIncomingData (C:\Users\username\projectDirectory\node_modules\mongodb\lib\cmap\message_stream.js:144:12)
at MessageStream._write (C:\Users\username\projectDirectory\node_modules\mongodb\lib\cmap\message_stream.js:42:5)
at doWrite (_stream_writable.js:441:12)
Hi, I'm trying to use the library to insert a new document that has a UUID as id in my collection. I would like this collection to have a validation schema to make sure that every ids of the documents inserted are UUIDs. However, when I'm specifying the BSON type 'object', the validation won't pass.
I have seen in the examples that I could use mongoose, but I would prefer the validation to be perform at the database level. Do you have any idea of how I could make this work or any explanation of why it is not working? Thank you!
Db migration code:
And the error I get