Comments (8)
Well, the underlying error is that attaching (or deleting attachments) is just a normal update to a document. It requires a revision ID just like any other update.
You can either add ?rev=...
to the query string (path), or add a header If-Match: ...
. See the attachment documentation.
What would be great is for nano to do the right thing transparently, either fetching first to get a revision, or else add the correct header if the _rev
is known.
from nano.
Can I ask you where did you learn about nano? If it was a blogpost I would like to cross post this response.
409 means conflict. Meaning you are trying to update but not specifying the rev.
If this isn't enough help I got this from the documentation regarding specifying revs:
https://github.com/dscape/nano/blob/master/nano.js#L467-#L470
So you need to get the document, see the latest rev, and update the attachment according to the rev.
Or you can simply delete the document which will reset the rev.
If this isn't enough I can write a working example.
Also advice you to read the free CouchDB book by @jchris http://guide.couchdb.org/editions/1/en/index.html
from nano.
What would be great is for nano to do the right thing transparently, either fetching first to get a revision, or else add the correct header if the _rev is known.
@jhs do you think this would be expected behavior? I would expect it to throw 409 if I don't know the rev, e.g. I might be updating the wrong attachment ?
from nano.
Hi all,
I found the problem. I was doing a check on the revision, but because it was doing an update before adding the attachment the revision number was changing.
Dscape: I found nano through a friend, and he pointed me to this site: http://writings.nunojob.com/2011/08/nano-minimalistic-couchdb-client-for-nodejs.html
from nano.
Great @xsyn - btw doing a cms in a document database makes a lot of sense :) doing it in a relational db, not so much :P
from nano.
:) I'm still getting my head around the user management though.
Thanks for your help.
from nano.
There's a special _users
database where you store your users.
Check the session tests for some pointers
from nano.
@dscape yes, sorry, I misunderstood. For some reason I thought the doc was already known in state somewhere.
from nano.
Related Issues (20)
- Does nano support purge? HOT 2
- db.attachment.get file- 'could not be opened because it is empty'
- Can not get correct userctx HOT 2
- Couch DB 2 compatibilty HOT 3
- bulk() with _deleted:true causes error HOT 3
- db.multipart.get does not work with Cloudant Local 1.0.0.5 HOT 1
- Enable permanent replication by writing to "_replicator" database instead of "_replicate" database. HOT 3
- Support temp view
- Doubt on db access of live app HOT 2
- What is the keys in view function based on? Is it the key you emit in the views/map function? HOT 1
- How do you update _rev to update a document?
- uploaded files displaying base64 data in the browser (attachments not viewable)
- Problem with OR -clauses? HOT 1
- Error: badarg every few hours
- Error: {error,emfile} HOT 1
- Example Lazy Creation of View
- Query string encoded when using array of keys
- Database permissions
- db.fetch array of id error
- Attempting to return simple list of documents, small issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nano.