Current working solution that I came up with... seems to work, but it looks a bit hacky. If you see the TODO comment, that is what I'd love to be able to do... I'm just wondering if it's possible at this point. This allows me to control what the user model shows/hides, so I'm a bit happier.
Schema.js
var User = describe('User', function() {
property('userid', String);
property('name', String);
property('email', String);
set('restPath', pathTo.users);
});
var Hash = describe('Hash', function () {
property('time', Number);
property('count', Number);
property('data', new Array());
set('restPath', pathTo.hashes);
});
hashes_controller.js
var options = {
host: 'api.local',
port: 80,
path: '/users',
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
};
var http = require('http');
http.get(options, function(res) {
var output = "";
res.on('data', function(chunk) {
output += chunk;
});
res.on('end', function() {
var obj = JSON.parse(output);
var data = {};
data.msec = obj.msec;
data.count = obj.count;
data.users = [];
// TODO: Ideally, this is what I would like to do
// var hash = new Hash(obj);
for (var i = 0; i < obj.data.length; i++) {
var user = new User(obj.data[i]);
data.users.push(user);
}
send({code: 200, data: data});
});
});