Skip to content

Instantly share code, notes, and snippets.

@jrgleason
Created April 18, 2014 23:10
Show Gist options
  • Save jrgleason/11068038 to your computer and use it in GitHub Desktop.
Save jrgleason/11068038 to your computer and use it in GitHub Desktop.
exports.index = function(req, res){
db.list('category')
.then(function (result) {
var categories = result.body.results;
var catsArr = new Array();
console.log(JSON.stringify(categories));
for(var i=0,len=categories.length; i<len; i++){
console.log(i);
db.newGraphBuilder()
.get()
.from('category', categories[0].path.key)
.related('products')
.then(function (res) {
console.log("Test: "+JSON.stringify(res));
})
}
res.render('index', { title: 'Express', categories: catsArr });
})
.fail(function (err) {
console.log("err2 "+ JSON.stringify(err));
})
};
//Produces
//[{"path":{"collection":"category","key":"key","ref":"edf5bab1c4726ad5"},"value":{"name":"Music","imgurl":"http://www.recorddept.com/wp-content/uploads/2010/01/WoodyPines%E2%80%93CountingAlligators.jpeg"}}]
//0
//err2 {}
exports.index = function(req, res){
db.list('category')
.then(function (result) {
var categories = result.body.results;
var catsArr = new Array();
console.log(JSON.stringify(categories));
for(var i=0,len=categories.length; i<len; i++){
console.log(i);
}
res.render('index', { title: 'Express', categories: catsArr });
})
.fail(function (err) {
console.log("err2 "+ JSON.stringify(err));
})
};
//Produces
//[{"path":{"collection":"category","key":"6d411deb-4f3e-4c09-83a2-8f93696d3652","ref":"edf5bab1c4726ad5"},"value":{"name":"Music","imgurl":"http://www.recorddept.com/wp-content/uploads/2010/01/WoodyPines%E2%80%93CountingAlligators.jpeg"}}]
//0
//But Orchestrate.io shows...
HTTP/1.1 200 OK
Date: Fri, 18 Apr 2014 20:25:55 GMT
Content-Encoding: gzip
X-ORCHESTRATE-REQ-ID: a505db40-c737-11e3-96ab-12313d2f9238
Server: nginx
Vary: Accept-Encoding, User-Agent
Content-Type: application/json
Connection: keep-alive
Content-Length: 230
{
"count": 2,
"results": [
{
"path": {
"collection": "product",
"key": "key",
"ref": "9bfb169ff7655254"
},
"value": {
"name": "Item 1",
"desc": "This is a simple item"
}
},
{
"path": {
"collection": "product",
"key": "Key",
"ref": "19b43cad67f3f186"
},
"value": {
"name": "This is item 2",
"desc": "This is another simple item"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment