I have the following scheme in the database:
const randomSchema = new Schema({ elem1: { type: String , required: true } , elem2: { type: [Number] , default: [] , required: true } , }) More I removed as useless
As we can see - in the field elem2 we have an array of numbers.
What do I need to do:
Suppose I have the number 8855.
I need to check if there is such a number among the elements of this array, and if it is, then delete, and if not, add it to the array.
The code did not attach, because I could not write something a little closer to this functionality.