我正在尝试获取已登录用户的联系人列表,但我不知道如何找到当前用户。我从 Parse.com 知道你使用 Parse.User.current() Stackmob 有这样的东西吗?
下面的代码演示我在寻找什么。
$(window).load(function () {
var user = StackMob.User;
var Contacts = StackMob.Model.extend({ schemaName: 'contacts' });
var myContacts = new Contacts();
var q = new StackMob.Collection.Query();
q.equals('sm_owner', user);
q.orderAsc('FirstName'); //sort by title in ascending order
q.setRange(0, 9); //get the first 10. second 10 would be setRange(10,19)
myContacts.query(q, {
success: function (model) {
console.debug(model.toJSON()); //JSON array of matching Todo objects
},
error: function (model, response) {
console.debug(response);
}
});
});
我使用下面的代码得到了我想要的东西,但是拥有 ('sm_owner','user/thomas') 有点没用。
$(window).load(function () {
var Contacts = StackMob.Model.extend({ schemaName: 'contacts' });
var myContacts = new Contacts();
var q = new StackMob.Collection.Query();
q.equals('sm_owner', 'user/thomas');
q.orderAsc('FirstName'); //sort by title in ascending order
q.setRange(0, 9); //get the first 10. second 10 would be setRange(10,19)
myContacts.query(q, {
success: function (model) {
console.debug(model.toJSON()); //JSON array of matching Todo objects
},
error: function (model, response) {
console.debug(response);
}
});
});