我需要转换一百万个文档。每个文档都是这样的:
{
"_id": "00082786797c0a31ab8b5e67fb0000dc",
"_rev": "3-d67692b1c94b936ae913bf7ea4896bed",
"type": "Feature",
"properties": {
"timestamp": "2015-08-03 21:26:48.000",
"status": "on",
"avstatus": null,
"speed": "38",
"MS_DATE_TI": 1438576728000,
"STR_DATE_T": "1438576728000"
},
"geometry": {
"type": "Point",
"coordinates": [
-8784866.197274148,
4296254.156268783
]
}
}
我正在尝试为每条记录创建一个基于“MS_DATE_TI”属性的新属性。最好的方法是什么?
谢克斯,泰勒
答案 0 :(得分:0)
使用Python构建一个小脚本或直接在浏览器中使用PouchDB。
这里的代码应该是什么样的。
var n; //The number of documents to get for every bulkget. Use it as a limit
var lastKey; //The key used as startkey_docid parameter
while(true){
//AllDocs to get N documents starting from lastkey
//Update the documents locally by doing a loop
//Send the updates to the server
//If response.rows < limit, you probably have updated all the lines so break the loop
}
答案 1 :(得分:0)
感谢AlexisCôté。我最终利用了一些我的python技能(我还没有PouchDB技能):))
这就是我的所作所为:
加载python CouchDB库: https://pypi.python.org/pypi/CouchDB
阅读文档: http://pythonhosted.org/CouchDB/
写一个小脚本
import couchdb
couch = couchdb.Server()
db = couch['avl_multi_doc']
for id in db:
doc = db[id]
print doc['properties']['MS_DATE_TI']
doc['time'] = doc['properties']['MS_DATE_TI']
db[doc.id] = doc
点击“运行”,然后去观看马特洛克