1

Cheers! I get Foo (for example) object from remote server with an ID, which looks like this:

id: "5110e8b5a8fefe71e0000197"

But when I do:

App.Foo.find("5110e8b5a8fefe71e0000197")

it returns array of objects, which is wrong, 'cause all ID's are uniq in mongo.

> Array[112]

So, how to make it work?

UPDATE: My find function:

App.Foo.reopenClass({
  allFoos: [],
  find: function(){
    $.ajax({
      url: 'http://address/foos.json',
      dataType: 'jsonp',
      context: this,
      success: function(data){
        data.forEach(function(foo){
          this.allFoos.addObject(App.Foo.create(foo))
        }, this)
      }
    })
    return this.allFoos;
  }
});
4

1 回答 1

1

尝试使用这个:

App.Foo.findOne({_id: "5110e8b5a8fefe71e0000197"})
于 2013-02-06T10:24:35.530 回答