Q:

Is there a way in waterline / nodejs to not return all fields? Or should I filter the json?

I am writing a little REST API with nodejs, express and waterline. If I retrieve a record and return it with res.json(post); this contains data I don't want to display in the API (like IDs, associations, etc.).
Is there a way to tell waterline which fields to retrieve? If not, what would be the best way to whitelist what will be sent out?

A:

waterline
From waterline perspective, you can use select when you retrieve the records, example from the docs:
// Returns only the field name
Model.find({ where: { age: { '<': 30 } }, select: ['name'] })

You can also implement toJSON as suggested by @Rodrigo.
node.js / lodash
From node.js side of things you can also use lodash's pick(), example from the docs:
var object = { 'user': 'fred', 'age': 40 };
_.pick(object, 'user');
// → { 'user': 'fred' }

