Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4829

Always getting not null object even though there are no objects with these parameters;

$
0
0

@komi94 wrote:

I always get that object that I am returning is not null. My goal here is that when grades.get(‘firstObject’) === null to create new object. Its like it returns the object that exists no matter what are the parameters. Because I get the right student and subject in calling the alert order. Please tell me what is wrong. Here is the snippet of the code.

insertMark(val1, val2){
            var student = this.store.peekRecord(“student”, val1);
            var subject = this.store.peekRecord(“subject”, val2);
            var mark = this.get(‘mark’);

			alert(student.get('firstName') +  " " +  student.get('lastName'));
			alert(subject.get('title'));

			var grades = this.store.peekAll('grade');

			grades.find(function(item, index){
				const student2 = item.get('student');
				const subject2 = item.get('subject');
				if(student2 === student && subject2 === subject){
					return true;
				}
				return false;
			});

			if(grades.get('firstObject') !== null){
				alert("Object is null even though there is no object with those parameters. ");
			}
}

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles