I want to make documents, which can be updated/changed by one concrete user(the user which has created it). Document content wich all users can see but only the owner can change it. The question is: If I have user with username "TheUser" how can create his own document named "TheUserDocument". It's not a problem to use just Nodejs, Nano or something else for database.
Asked
Active
Viewed 210 times
1 Answers
0
This can be accomplished with a document update validation function. When you originally create the document, store the user who created it, then your update validation function might look something like this:
function(newDoc, oldDoc, userCtx, secObj) {
if ( oldDoc.creator == userCtx.name ){
return;
}
throw({forbidden: 'Permission denied.'});
}
You can read more about validation functions here: http://docs.couchdb.org/en/latest/ddocs.html#validate-document-update-functions

Matt Jennings
- 1,148
- 6
- 11
-
It's my mistake that didn't check CouchDB documentation. Thanks. P.S. Why my question has negative sign. I can't understand my mistake cause I am new :? – user3155167 Jan 09 '14 at 18:24
-
Someone downvoted your question, not to worry though, it's a perfectly fine question to ask – Matt Jennings Jan 09 '14 at 19:11