1.- I'm working with loopback-connector-rethinkdbdash
2.- On a remote method I need to retrieve some random records from my DB, this is the code so far.
(function(){
'use strict';
module.exports = (Heatmap) => {
var r = require('rethinkdb');
// Connect to RethinkDB
var p = r.connect({
host: 'rethink',
port: 28015,
db: 'livedata'
});
// Error Handler
function throwErr(err) {
throw (err);
}
// Random Remote Method
Heatmap.random = (cb) => {
p.then(function(conn) {
r.table('heatmap').run(conn, function(err, cursor) {
cursor.toArray(function(err, results) {
console.log('ALO-4', results)
cb(err, results);
})
})
}).error(throwErr);
}; // Heatmap.random
Heatmap.remoteMethod(
'random',
{
accepts : [],
returns : { arg : 'results', type : 'array', root : true },
http : { path : '/random', verb : 'get' }
}
); // Heatmap.remoteMethod
};
}).call(this);
3.- I've already followed this documentation: https://github.com/neumino/rethinkdbdash https://docs.strongloop.com/display/public/LB/Remote+methods#Remotemethods-Argumentdescriptions
4.- The thing is that the records or results return on the console.log('ALO-4') but they don't return in the browser...
I dunno what's going on, can someone help me?
Ty