@arnoldo.moen
In MongoDB, you can add a field description to a collection by using the collMod
command in the mongo shell. Here's how you can do it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
db.runCommand({ collMod: 'collectionName', validator: { $jsonSchema: { bsonType: 'object', properties: { fieldName: { bsonType: 'string', description: 'Field Description' } } } } }) |
Replace collectionName
, fieldName
, and Field Description
with your actual collection name, field name, and description respectively.
1
|
db.getCollectionInfos({name: 'collectionName'}) |
This will display the information about the specified collection, including the field description that was added.
That's it! You have successfully added a field description to a MongoDB collection.