Merge Object of type PTYPE<GEOMETRY> with other objects in RethinkDb

53 views Asked by At

i have following in my database and i want to merge it with other table . i have successfully merge other objects but when i run the following query

r.db('test').table('jaguar').get('7').merge(function(j) {
   return {
            jId: j("id"),
            createdAt: j("createdAt"),
            plocation: r.db("test").table("use").get(j('pass')('userId')).merge(function(p) {
                return p("location");
            })
          }
})

/////////////////////////////////////////////////////////////////////////////////////////// it throws following error

Cannot merge objects of type `PTYPE

and this is my dataset am using rethinkdb

"location": {
     "$reql_type$":  "GEOMETRY" ,
     "coordinates": [73.065455, 33.616539] ,
     "type":  "Point"
}
1

There are 1 answers

0
Etienne Laurin On

You can only merge JSON objects together, not other types like geometries. You can cconvert a geometry to JSON by using .toGeoJSON, but you'll have to convert it back into a geometry object before performing geo operations on it.