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 code snippet above doesn't seem to be functioning as expected. While I can easily perform operations on columns that already exist within the class, such as .equalTo("productType", "SHIRT")
, linking to the author field which resides in a separate User class seems challenging.
Is there a way to modify the query so that it only retrieves items where the "author" (a pointer) matches an objectId from 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);
}
});
}
});