[HELP] Deleting documents in couchDB

I completed the api addon for essentialmode and it is this

this is what you need to do to make it work yourself.

function exposedDB.deleteDocument(db, documentID, docrev, callback)
  PerformHttpRequest("http://" .. ip .. ":" .. port .. "/" .. db .. "/" .. documentID .. "?rev=" .. docrev, function(err, rText, headers)
      local response = json.decode(rText)
      print("Query:" .. "http://" .. ip .. ":" .. port .. "/" .. db .. "/" .. documentID .. "rText:" .. rText)
      if (response.ok) then
        callback(true)
      else
        callback(false)
      end
    end, "DELETE", "", {Authorization = "Basic " .. auth})
end

put that in your essentialmode db.lua file near the bottom and then this is how you call it

TriggerEvent('es:getPlayerFromId', source, function(user)
                TriggerEvent('es:exposeDBFunctions', function(db)
				db.getDocumentByRow('database name', 'identifier', user.identifier, function(dbuser)
                    db.deleteDocument('database name', dbuser._id, dbuser._rev)
					end)
                end)
            end)

I just told you : https://wiki.apache.org/couchdb/HTTP_Document_API#DELETE

I have looked at that and it really does do me any favors with making this work in lua…

I am just now testing a different revision that might work, but we will see.

Ok I got it to work and this is what you need to do to make it work yourself.

function exposedDB.deleteDocument(db, documentID, docrev, callback)
  PerformHttpRequest("http://" .. ip .. ":" .. port .. "/" .. db .. "/" .. documentID .. "?rev=" .. docrev, function(err, rText, headers)
      local response = json.decode(rText)
      print("Query:" .. "http://" .. ip .. ":" .. port .. "/" .. db .. "/" .. documentID .. "rText:" .. rText)
      if (response.ok) then
        callback(true)
      else
        callback(false)
      end
    end, "DELETE", "", {Authorization = "Basic " .. auth})
end

put that in your essentialmode db.lua file near the bottom and then this is how you call it

TriggerEvent('es:getPlayerFromId', source, function(user)
                TriggerEvent('es:exposeDBFunctions', function(db)
				db.getDocumentByRow('database name', 'identifier', user.identifier, function(dbuser)
                    db.deleteDocument('database name', dbuser._id, dbuser._rev)
					end)
                end)
            end)

You see, you didn’t need help :wink:
I already have mine

Eh, I still like to ask cause i have been up sense yesterday doing various things and i wanted to get this done before i went to sleep lol.

Ahah ^^ You got the information (the link I gave you), you got examples (essentialmode). That’s it

Well I found that link prior to you telling me it, its just I didnt know how to convert what that looked like into lua, however I got mostly everything right except I kept not putting in the rev lol.