Helloo! I am having problems with the response of my queries sent to ember cli app. For example, I have my models:
//models/post.js
import DS from 'ember-data';
var attr= DS.attr;
export default DS.Model.extend({
author: DS.belongsTo('author'),
title: attr('string'),
body: attr('string'),
date: attr('date')
});
//models/author.js
import DS from 'ember-data';
export default DS.Model.extend({
posts: DS.hasMany('post'),
name: DS.attr('string')
});
So ember expects a response in the following json format:
var posts= [
{
id: 1,
title:'Bananas',
author_id:1,
date: new Date(2014,5,4,9,0,0),
body:"mmm yum"
},
{
id: 2,
title:'Apples',
author_id:1,
date: new Date(2015,1,1,9,0,0),
body: "Try these poison apples"
}];
var authors= [{
id: 1,
name: "George",
posts:[1,2]
}]
***My problem is if I am getting my information from a query using Postgresql, how do I send the resulting rows in that format, I have a table with the author_id and the post_id that the author posted. Help please, thanks!!!