I need to know how many rows of a specific resource (App.User) exist in total.
I tried to return it in response, but Ember complains about not mapped properties and is expecting only array of records (users: [ "john", "fred"]
). I do not want to make an additional query to the server.
Is there any clean way to achieve this with Ember?
You need not make an additional query to the server. Once you get the data in datastore from the server, it stays there unless some record is dirty and you run a store.commit
So, after you get your records by saying
users = App.User.find()
you can simply do users.get('length')
and you will get the length. When you do this, an additional query to the server is not generated.
If you want this in a handlebars template, you can do {{this.length}}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With