I'm building a database with rethinkdb and koajs. Is there anyway in Reql to only deliver a specific field within a filter function? here is my code:
function bySwimmer() {
return function *(next) {
var qs = this.request.querystring;
var q = this.request.query;
//pulls data from the db
var cursor = yield r.table('swim').filter(function(swim) {
//if there is no query it will return all data else returns only the data specified by the query
if(qs == "") {
return swim.getField("fullName");
} else {
return swim('fullName').upcase().eq(q.fullname.toUpperCase());
}
}).run(this._rdbConn);
var result = yield cursor.toArray();
this.body = JSON.stringify(result);
yield next
}
}
getField() should only return that field but all the data is still sent to the browser.