I have a DB in CouchDB and I'm wondering if is it possible to create a view directly from python instead of using GUI. I'm a beginner in CouchDB and I need a function that's equivalent at SELECT DISTINCT in SQL and a view like
function (doc) {
if(doc.MovieId == "1254")
emit(doc.Rating, 1);
}
is the ideal. The problem is that I've to do this view for much more MovieId
s (taken from keyboard input).
I'm asking you if is possible to create/delete views like this directly from python because on the net I've found nothing. If isn't possible, is that a good idea to make a Mango query and map results by myself?
---EDIT---
json_data = {
"_id": "_design/titaRat",
"_rev": "3-ceb11154b13457c55b1f98f4e9d15b03",
"views": {
"titRat": {
"map": "function (doc) { var id_prefix = \"ratings :\"; if(doc._id.substr(0, id_prefix.length) === id_prefix && doc.MovieId == \"1721\") emit(doc.Rating, 1);}",
"reduce": "_count"
}
},
"language": "javascript",
"options": {
"partitioned": False
}
}
db.save(json_data)
ResourceConflict: ('conflict', 'Document update conflict.')
I got this error, but there aren't document that have this name