In Ember.js,
I am trying to perform a query of all posts with a matching key. Btw, this is in Firebase. My data looks something like this:
I'm trying to query specific posts
based off the key
property (multiple posts may have the same key
property value).
So here is my model(params)
in my route
route/stuff.js
export default Ember.Route.extend({
model(params) {
console.log(params.site_id);
return this.store.query('post', { "key": params.site_id} );
}
})
And here is me trying to display my posts in my template:
template/stuff.hbs
<div class="panel panel-default">
<div class="panel-heading">
Post Title:
</div>
<div class="panel-body">
<div class="col-lg-6 col-md-6 col-sm-6 margin-top-1em">
<ul class="li-type-none">
<li>Post Author: </li>
</ul>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<ul class="nav nav-pills margin-top-small">
Edit
<button class="btn btn-danger btn-s" >Remove Post</button>
</ul>
</div>
</div>
</div>
And, the good news is that my posts
will display. The bad news is that ALL posts display. Even ones that don't have the right key. Why is my query returning all the posts instead of only the ones that have the right key attribute?
Here is some extra information that maybe helpful:
model/post.js
import DS from 'ember-data';
export default DS.Model.extend({
author: DS.attr('string'),
title: DS.attr('string'),
content: DS.attr('string'),
key: DS.attr('string'),
date: DS.attr('date', { defaultValue() { return new Date(); }}),
site: DS.belongsTo('site'),
isLocked: DS.attr('boolean'),
lockedContent: DS.attr('string'),
metaData: DS.attr('string')
});
Also, here is how it looks in the URL (note that the key
attribute is passed into the url)
http://localhost:4200/posts/-D2312jsj23u1828u42/stuff
Thank you!
Aucun commentaire:
Enregistrer un commentaire