How can I store a rethinkdb geometry point with feathersjs?

63 Views Asked by At

I'm using feathersjs with feathers-rethinkdb and I'm trying to store a point in the database with the create method of my service. I have created this hook to transform a json in to a rethinkdb point :

const transformCoords = hook => {
  const {r}  = hook.service.options;
  const {latitude, longitude} = hook.data.coords;
  hook.data.coords = r.point(parseFloat(longitude), parseFloat(latitude));
};

but when I do a POST request for creating a point and that hook is being executed my backend returns this error:

{
    "name": "GeneralError",
    "message": "`toJSON` takes 0 argument, 1 provided after:\nr.point(0, 0)",
    "code": 500,
    "className": "general-error",
    "data": {},
    "errors": {}
}

If I check the database, that point is being created ok as a rethinkdb point and I can do geospatial queries, so everything seems to be ok, but I want to stop sending that message error, and also I want to know what I'm doing wrong.

Thank you very much.

0

There are 0 best solutions below