Skip to content

Could give a example for creating, deleting, updating, selecting? #121

Answered by kkharji
kdurant asked this question in Q&A
Discussion options

You must be logged in to vote

Here's something I just wrote, I will try to include example in the readme soon

local has_sqlite, sqlite = pcall(require, "sqlite")
if not has_sqlite then
  print "Couldn't find sqlite.lua. Cannot use persistent history"
  return nil
end

---@class NeoclipEntry @entry content
---@field regtype string
---@field contents string[]
---@field filetype string

---@class NeoClipTable: sqlite_tbl
local M = sqlite.tbl("neoclip", {
  id = true,
  regtype = "text",
  contents = "luatable",
  filetype = "text",
})

function M:init(config)
  config = config or {}
  local db_path = config.db_path or vim.fn.stdpath "data" .. "/databases/neoclip.sqlite3"
  self:set_db(sqlite.new(db_path)) --- directory e…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kkharji
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #113 on September 21, 2021 21:04.