String Data Type
const schema = new Schema({ Title: { type: String } })

Options:
Required: If you choose this option, it means that users must fill in the required fields before submitting data to the database. This ensures that all necessary information is collected and avoids submitting incomplete data. It prompts users to provide input in the designated fields that must be filled.
Ex. It will not take blank fields in the database.
isPrivate: If you choose this option, it means that the system will keep the information entered in that field confidential and hidden from the user. This option is especially helpful when collecting sensitive data that should not be visible to the user.
Ex. It will not be visible to the user in the response.
isArray: If you choose this option, it means the selected field will be set up as an array with a numeric data type. This option is helpful when storing multiple items as a single entity.
Ex. It will take an array like ['title', 'description']
unique: If you choose this option, it means that the system will require each value in that field to be different from the others. This is useful when you want to avoid duplicates in specific data fields, such as user account numbers.
Ex. when the user adds added value for that field, it won't allow taking that value again.
Convert To Uppercase: If you choose this option, it means whatever value is added in that field will be saved in uppercase in the database.
Ex. If the user wants all their value-added only capital in the database
Trimmed String: If you choose this option, it means that it'll remove leading and trailing whitespace from a string.
Ex. title= title to title= title
Searchable: If you choose this option, it means that it can be used to search for specific information in the database by functioning as a query criterion. For example, if you mark a user's name field as searchable, users can search for other users by their name.
Ex. we can search with this field for matching documents.
Sortable: If you choose this option, it means that the field becomes eligible for use in sorting the elements of a collection resource in either ascending or descending order, enhancing the efficiency of data retrieval and organization
Ex. it will sort the documents by selected field when we search the documents.
RegExp Pattern: If you choose this option, it means the user wants to create a validator that checks if the value matches the given regular expression then reg add on that field
Ex. reg looks like - ^[\w-.]+@([\w-]+.)+[\w-]{2,4}$
Add Range: If you choose this option, it means that you can set limitations on the length of a designated field, specifying both a minimum and a maximum number. This is particularly useful in cases where you need to restrict the amount of data that can be entered into a field.
Ex. we want only 3 to 10 characters on it then max Length = 10 and Min Length = 3
Has Default Value: if you choose this option, it means that the field will be automatically filled with a default value if no other value is entered. This helps ensure that the field always contains data, preventing incomplete or missing information.
Ex: If the user has not entered the value then it will take this value
Last updated