couchdb 文档 属性 基于现有 属性:批量更新
couchdb doc property based on existing property: bulk update
我有一百万个文档需要转换。每个文档如下所示:
{
"_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" 属性 为每条记录创建新的 属性。最好的方法是什么?
谢谢,泰勒
要么在 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
}
谢谢亚历克西斯·科特。我最终利用了我的一些 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
点击运行然后去观看马特洛克
我有一百万个文档需要转换。每个文档如下所示:
{
"_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" 属性 为每条记录创建新的 属性。最好的方法是什么?
谢谢,泰勒
要么在 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
}
谢谢亚历克西斯·科特。我最终利用了我的一些 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
点击运行然后去观看马特洛克