2016-05-31 5 views
0

ファイルからRethinkdbにデータをインポートしています。Rethinkdbの既存データからポイントを作成する

データはこのようになります(これは偽のデータ)

[ 
    { 
    "firstName": "Keeley", 
    "lastName": "Leannon", 
    "createdAt": "2016-05-10T19:55:38.823Z", 
    "location": { 
     "lat": 52, 
     "lng": 0.07687, 
     "lastUpdated": "2016-05-16T03:21:25.082Z" 
    }, 
    "company": "Breitenberg and Sons", 
    "jobTitle": "Dynamic Group Facilitator", 
    "email": "[email protected]" 
    }, 
    { 
    "firstName": "Henri", 
    "lastName": "Ernser", 
    "createdAt": "2016-05-21T11:51:54.581Z", 
    "location": { 
     "lat": 52, 
     "lng": -0.74853, 
     "lastUpdated": "2016-04-28T21:15:26.786Z" 
    }, 
    "company": "Gleason, Dickens and Cassin", 
    "jobTitle": "Lead Data Consultant", 
    "email": "[email protected]" 
    } 
] 

は今、私は緯度をlocation.lng & location.latフィールドからpointオブジェクトを作成し、削除したい、とのLNG分野場所フィールドは今、この

"location": { 
      "point": -0.74853, 52, 
      "lastUpdated": "2016-04-28T21:15:26.786Z" 
     }, 

私は、ファイルからのインポート、および限り、私はドキュメントに伝えることができるようてるように見えるので、そう、ReQLを使用してファイルから直接インポートする方法はありません私はコマンドラインとtからインポートを行う必要がありますhenはインポート後に各文書を変更します。

上記の作業を進める上での注意点はありますか?

答えて

0

このコマンドは、私が必要なものに十分に近い

r.db('test').table('people').update(function(item) { 
    return { 
    location: { 
     geometry : r.point(
     item("location")("lng"), 
     item("location")("lat")), 
     lastUpdated : item("location")("lastUpdated"), 
     lat: r.literal(), 
     lng: r.literal() 
    } 
    } 

})

"location": { 
     "geometry": { 
      "$reql_type$": "GEOMETRY" , 
      "coordinates": [-0.94645 ,51] , 
      "type": "Point" 
     } , 
     "lastUpdated": "2016-05-04T01:38:48.786Z" 
    } 
ような位置オブジェクトをもたらす

関連する問題