Cloudant 视图仍然包含 DOC 之外不需要的 ID 键
Cloudant view still including unwanted id keys outside from the DOC
我在使用 couchdb cloudant 数据库时无法删除不需要的数据。
我已经完成了一个 couchdb 视图,一个像这样的对象数组:
[
{},
{}
]
LOOK AT THE WELL DONE VIEW
现在,当查询 couchdb 时,它仍然发送格式错误的对象数组:
我只想要这个:
[
{mydoc1content},
{mydoc2content}
]
当前给了我这个:
[
{id:1,value:1:key:1;doc:{mydoc1content}},
{id:2,value:2:key:2;doc:{mydoc2content}}
]
如何只获取文档?不是不需要的 id、key 和 docs 值?
我认为它叫做 'metadata',如何摆脱这些不需要的元数据东西?它阻碍了我进一步发展。
给出:
total_rows 16
offset 0
rows
0
id "1"
key "1"
value 1
doc {…}
1
id "10"
key "10"
value 1
doc {…}
2
id "11"
key "11"
value 1
doc
_id "11"
_rev "1-b532f5d0dbc395875dc5fb04bce8fb58"
identifiant 11
prenom "Ricardo"
nom "Izecson dos Santos Leite"
categorie 1
ville "São Paulo"
age 34
date_embauche "2017-06-26T22:00:00.000Z"
salaire 950
vitesse 85
agilite 70
deduction 54
photo "kaka.jpg"
poste "Milieu Offensif"
3
此格式错误,我无法在我的应用程序中使用它。
我怎么能去掉 id "1"
键“1”
值 1
并且只得到一个简单的对象数组?
正如我在 CouchDB 的 Github 存储库中所建议的那样,您应该在查询数据后对其进行操作。
例如,您可以执行以下操作:
const getDocsFromViewResult = rawData => rawData.map(entry => entry.doc);
const data = [{
id: 1,
key: 1,
doc: {
_id: '1234',
name: 'johnny'
}
}];
console.log(getDocsFromViewResult(data));
我在使用 couchdb cloudant 数据库时无法删除不需要的数据。
我已经完成了一个 couchdb 视图,一个像这样的对象数组:
[
{},
{}
]
LOOK AT THE WELL DONE VIEW
现在,当查询 couchdb 时,它仍然发送格式错误的对象数组:
我只想要这个:
[
{mydoc1content},
{mydoc2content}
]
当前给了我这个:
[
{id:1,value:1:key:1;doc:{mydoc1content}},
{id:2,value:2:key:2;doc:{mydoc2content}}
]
如何只获取文档?不是不需要的 id、key 和 docs 值? 我认为它叫做 'metadata',如何摆脱这些不需要的元数据东西?它阻碍了我进一步发展。
给出:
total_rows 16
offset 0
rows
0
id "1"
key "1"
value 1
doc {…}
1
id "10"
key "10"
value 1
doc {…}
2
id "11"
key "11"
value 1
doc
_id "11"
_rev "1-b532f5d0dbc395875dc5fb04bce8fb58"
identifiant 11
prenom "Ricardo"
nom "Izecson dos Santos Leite"
categorie 1
ville "São Paulo"
age 34
date_embauche "2017-06-26T22:00:00.000Z"
salaire 950
vitesse 85
agilite 70
deduction 54
photo "kaka.jpg"
poste "Milieu Offensif"
3
此格式错误,我无法在我的应用程序中使用它。 我怎么能去掉 id "1" 键“1” 值 1 并且只得到一个简单的对象数组?
正如我在 CouchDB 的 Github 存储库中所建议的那样,您应该在查询数据后对其进行操作。
例如,您可以执行以下操作:
const getDocsFromViewResult = rawData => rawData.map(entry => entry.doc);
const data = [{
id: 1,
key: 1,
doc: {
_id: '1234',
name: 'johnny'
}
}];
console.log(getDocsFromViewResult(data));