I searched and didn't found, can I delete a field of a couchdb's document using curl ?
The most I can do is delete a document:
curl -X DELETE http://localhost:5984/users/jack?rev=1-cee2abbbe4afefa9b3b5db10260c0c94
Thanks.
If you want delete any field, you need edit document via PUT method, where you send all fields of document, id and rev. included, but without field for delete.
Http method DELETE is only for delete complete document, no field in that:)
I believe you're supposed to execute a PUT request containing the modified document, and the _rev of the version you're modifying.
Related
I know how to get the last document created by couchDB :
http://<IP>:5984/<DBname>/_changes?descending=true&limit=1
But my question is how to get the doc ID of the first document?
You can exclude the descending=true parameter from the URL and use only http://<IP>:5984/<DBname>/_changes?limit=1. However, according to the docs:
Only the most recent change for a given document is guaranteed to be provided, for example if a document has had fields added, and then deleted, an API client checking for changes will not necessarily receive the intermediate state of added documents.
So if the first document has been modified, it won't appear as the first item in the changes feed.
A way to achieve this would be to add a date_created timestamp in the documents when they are created and use a view that emits this field so that the documents are sorted by creation time.
I followed this link enabling me to setup a hotspot in a richtext field - works like charm.
http://ozinisle.blogspot.de/2010/11/lotusscript-code-to-append-hotspot-to.html
Only problem is, as the user(s) usually do(es) not have deletion rights, the document created by the import stays stored in the database. In LotusScript e.g. I can create a new temporary document and work with it, and if I'm not saving it, it just disappears at the end of the function.
Is there a similar way or parameter for DXL import which allows me to just drop the document after I got my rtitem?
Alternatively, can someone point out to me if it is possible to create only the temporary richtext item in/on a document I created as tempdoc via LotusScript?
My search on the web did not get any results and my tries to reduce the linked function always resulted in the error 4518 (which is described in the help document of "DXLImporter"); if I read the help right, the DXLImporter only supports the db as valid output (thus expecting documents being created via DXL).
I don't see a way to import DXL without creating a document.
The easiest solution is to create the temporary document in users "cache.ndk". The user has definitely the right to delete documents there. So, you'd replace the line "Set db = session.CurrentDatabase" in code you linked to with
Set db = session.Getdatabase("", "cache.ndk", false)
The rest of the code would stay the same.
As an alternative, use the more classic approach running an agent on server to delete the temporary document. Create an agent which deletes the document, set property "Run on behalf of" to someone who is allowed to delete documents in database and call the agent from your script with
agent.RunOnServer(noteID)
in my Lotus Notes agent, I temporarily created some documents using a new form (with a richtext field in the form), and in the end of the code, I have "Call TempDoc.Remove(True)", when the program execute this line of code, I got error "Notes error: No documents were deleted", then I commented out this code to let the document saved in the current database, so I manually delete those documents created by my program by click Delete key, but I got the same error "No documents were deleted", I have Manager access with delete option in the database ACL,
Does anybody know why I got that error?
By the way, if I created a new document by using the default form which is not the form used in my program above, then I can delete it.
So, the question may be: what kinds of documents created in the notes database can NOT be deleted by a id with Manager and Delete option?
The NotesDocument.Remove(true) method may be trying to do a "soft deletion", but the database may not be properly set up for soft deletes. If you don't care about soft deletes, then try the NotesDatabase.RemovePermanently(true) method instead.
I am putting a document into couchdb like this:
curl -X PUT http://localhost:5984/bucket/keyname_1 \
-d '{"foo":"bar"}'
This works just fine as long as the document doesn't already exist. If it does exist, I need to include a "_rev" key to validate that I am updating an existing document:
curl -X PUT http://localhost:5984/bucket/keyname_1 \
-d '{"_rev":"2-207df9da","foo":"bar"}'
If the _rev key is missing, or if the _rev key is doesn't match what's in the existing record, this throws a "conflict" error. This is how you know that a revision isn't being thrown away.
But what if I want to write it unconditionally, and bypass this check?
I have a design where I am updating the main record, with the check, and then I want to save a brief summary record with only a couple fields that can be easily grabbed and downloaded for a summary screen. Since I just updated the main record, I know that I have the latest copy. I just want to do a write, and I don't want to have to do a read first just to get the _rev. This would be redundant.
Is there any way that I can modify my request to tell couchbase to skip the _rev check and just put the document in unconditionally?
So you have two documents that you want to update: main and summary. Even if you have the latest version of main, will that actually mean you have the latest version of summary as well or do you just want force the last no matter what? If, then you might have a look at Update handlers: http://wiki.apache.org/couchdb/Document_Update_Handlers
Also, if you go with some kind of secondary GET to fetch the latest _rev, use a cheaper HEAD request.
EDIT: BTW, why having two separate documents? Is the Summary one in fully complete with the Main one? All all the members found there? Could you then perhaps use Show or list functions? http://wiki.apache.org/couchdb/Formatting_with_Show_and_List
Instead of PUTting the record, why not POST a new one?
That way, you keep a full record of all such log events, but you don't have to deal with document conflicts.
For some enhancing reason, I have added some new fields in my form. It is having default value.
But the existing document is not getting updated with the new fields.
I am having a thousands of documents. I can not open, Edit and save. I tried to save the document from backend. I can not believe, that was also not working.
Is their anyway for updating documents?
Create a view action button that executes this command:
#Command[ToolsRefreshAllDocs])
If you prefer using backend classes, you need call notesDocument.ComputeWithForm( False, False ) before saving document.