BlogApp.Collections.Blogs = Parse.Collection.extend({
model: BlogApp.Models.Blog,
query: (new Parse.Query(BlogApp.Models.Blog)).equalTo("author", "xMQR0A1Us6").descending('createdAt').limit(9)
});
The above doesn't seem to work. I can do all sorts of things with columns that already exist in the class, such as .equalTo("productType", "SHIRT"), for example, but I can't link to the author which exists in a separate class User.
How can I restrict the query to retrieve only items from "author" (a pointer) equal to an objectId which exists in the User class?
Model:
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);
}
});
}
});