【发布时间】:2016-02-04 22:51:00
【问题描述】:
BlogApp.Collections.Blogs = Parse.Collection.extend({
model: BlogApp.Models.Blog,
query: (new Parse.Query(BlogApp.Models.Blog)).equalTo("author", "xMQR0A1Us6").descending('createdAt').limit(9)
});
上述方法似乎不起作用。我可以对类中已经存在的列执行各种操作,例如 .equalTo("productType", "SHIRT"),但我无法链接到存在于单独类 User 中的作者。
如何限制查询仅从“作者”(指针)中检索与 User 类中存在的 objectId 相等的项目?
型号:
BlogApp.Models.Blog = Parse.Object.extend('MarketDesign', {
update: function(form) {
if ( !this.get('ACL') ) {
var blogACL = new Parse.ACL(Parse.User.current());
blogACL.setPublicReadAccess(true);
this.setACL(blogACL);
}
BlogApp.category.id = form.category;
this.set({
'title': form.title,
'url': form.title.toLowerCase()
.replace(/[^\w ]+/g,'')
.replace(/ +/g,'-'),
'category': BlogApp.category,
'comment': form.content,
'author': this.get('author') || Parse.User.current(),
'authorName': this.get('authorName') || Parse.User.current().get('username'),
'time': this.get('time') || new Date().toDateString()
}).save(null, {
success: function(blog) {
Parse.history.navigate('#/admin', { trigger: true });
window.location.reload();
},
error: function(blog, error) {
console.log(error);
}
});
}
});
【问题讨论】:
标签: javascript parse-platform collections