If you already inserted the document into the database and want to add a point to that document, you can use the udpate
command with the toGeojson
command in order to do that.
Here's how that would look:
r.table('30711279').get(101)
.update(function (row) {
return {
'route': r.line(r.args(
row('route').toGeojson()('coordinates')
.append([ -120, 85 ])
))
}
}, {nonAtomic: true })
Basically, I'm creating a new line in the route
property. I'm passing it all the old points as an array and then appending a new tuple with the longitude and latitude.
If you still haven't inserted the document into the database and wanted to add a point to that line, you could just do this:
var arrayOfPoints = [[-122.423246,37.779388], [-121.886420,37.329898]];
var point = [ -120, 57 ];
r.table('geo').insert({
id: 101,
route: r.line(r.args(arrayOfPoints.concat(point)))
}).run(conn, callback);