A user adds a new object to the model. Then I want to check if a value already exists in my model, but I don’t want it to include the most recently added object in my model because then it will always return true. Basically I want to loop through the model.length() - 1. What is the best way to go about doing so?
If you can give a bit more explanation for what you’re trying to achieve, I can suggest how to refactor it. How will you use the result of this check?
I am trying to add a new object to my Ember model and then check to see if there is a match already in the system. But every time I add a new object, it will always return true because I just added it to my database.
For instance I have a model with [dog, cat, fish]. I want the user to add a new animal [horse]. Then I want to check if that new value already exists in my array and return the object at that index if it does.
My problem is that it adds the value to the array THEN it checks to see if the value is in it. Which will always be true since I just added it.