mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2026-02-04 23:02:06 +00:00
feat: add an command to delete an entry from DB (#152)
* feat: add an command to delete an entry from DB Fix #151 * test: add tests for frecency:delete() * docs: add note for FrecencyDB
This commit is contained in:
committed by
GitHub
parent
daf59744f6
commit
ca5fa5326f
@@ -196,4 +196,17 @@ function Native:raw_save(tbl)
|
||||
assert(not async.uv.fs_close(fd))
|
||||
end
|
||||
|
||||
---@param path string
|
||||
---@return boolean
|
||||
function Native:remove_entry(path)
|
||||
if not self.table.records[path] then
|
||||
return false
|
||||
end
|
||||
self.table.records[path] = nil
|
||||
wait(function()
|
||||
self:save()
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
return Native
|
||||
|
||||
@@ -145,4 +145,11 @@ function Sqlite:remove_files(ids)
|
||||
self.sqlite.files:remove { id = ids }
|
||||
end
|
||||
|
||||
---@param path string
|
||||
---@return boolean
|
||||
function Sqlite:remove_entry(path)
|
||||
local exists = not not self.sqlite.files:get({ where = { path = path } })[1]
|
||||
return exists and self.sqlite.files:remove { path = path } or false
|
||||
end
|
||||
|
||||
return Sqlite
|
||||
|
||||
Reference in New Issue
Block a user