I have a react application that performs CRUD operations on data stored in mongodb in the cloud.mongodb.com.
The schema of the data in my react looks like this:
const restaurantSchema = new Schema({
"uuid": {
"type": "string"
},
"name": {
"type": "string"
},
"city": {
"type": "string"
}
}, {timestamps: true});
I would like to add a new field called "preference" of type number.
My questions are:
- How do I add this new field of "preference"?
- Can I give it a default value of say 1 when I add this new field? (There are 900 entries in the mongodb.)?
- Can I give the "preference" value based on the order of the "name" field in ascending order?
thanks.