有没有办法在CouchDB中执行以下操作?一种通过给定键返回唯一,不同值的方法?
SELECT DISTINCT field FROM table WHERE key="key1"
'key1' => 'somevalue'
'key1' => 'somevalue'
'key2' => 'anotherval'
'key2' => 'andanother'
'key2' => 'andanother'
Run Code Online (Sandbox Code Playgroud)
例如:
http:// localhost:5984/database/_design/designdoc/_view/distinctview?key = "key1"将返回['somevalue']
http:// localhost:5984/database/_design/designdoc/_view/distinctview?key = "key2"将返回['anotherval','andanother']