Skip to content

Instantly share code, notes, and snippets.

@pagameba
Created June 5, 2013 13:00
Show Gist options
  • Save pagameba/5713679 to your computer and use it in GitHub Desktop.
Save pagameba/5713679 to your computer and use it in GitHub Desktop.
/*jslint node:true, sloppy: true, indent: 2, nomen: true, white: true */
var util = require('util')
, response = require('cradle/lib/cradle/response')
, mockJSON = {
total_rows: 1,
offset: 0,
rows: [{
id: 'some-id',
key: 'some-key',
value: {
_id: 'some-id',
_rev: 'some-rev',
live: true,
name: 'test',
owner: 'some-owner',
type: 'Environment',
version: 'dev'
}
}]
}
, resp = new response.Response(mockJSON, null)
;
console.log(util.inspect(resp, true, null, true));
var a = resp.map(function (env) {
return {
id: env._id,
active: env.name === 'development',
name: env.name,
version: env.version,
live: env.live
};
});
console.log(util.inspect(a, true, null, true));
{
"name": "array_test",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "",
"author": "",
"license": "BSD",
"dependencies": {
"cradle": "~0.6.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment