You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Could give a example for creating, deleting, updating, selecting? #113
changed the title [-]Can give a example for creating, deleting, updating, selecting?[/-][+]Could give a example for creating, deleting, updating, selecting?[/+]on Sep 6, 2021
Here's something I just wrote, I will try to include example in the readme soon
localhas_sqlite, sqlite=pcall(require, "sqlite")
ifnothas_sqlitethenprint"Couldn't find sqlite.lua. Cannot use persistent history"returnnilend---@classNeoclipEntry @entry content---@fieldregtypestring---@fieldcontentsstring[]---@fieldfiletypestring---@classNeoClipTable:sqlite_tbllocalM=sqlite.tbl("neoclip", {
id=true,
regtype="text",
contents="luatable",
filetype="text",
})
functionM:init(config)
config=configor {}
localdb_path=config.db_pathorvim.fn.stdpath"data" .."/databases/neoclip.sqlite3"self:set_db(sqlite.new(db_path)) --- directory ensuring should be out of this moduleendM:init() --- called outside the module to set user db path---Insert new neclip entry---@paramentryNeoclipEntry[] | NeoclipEntryfunctionM:insert(entry)
-- do some pre processing before inserting a rowreturnself:__insert(entry)
endM:insert {
{
contents= { "line 1", " line 2", "line 3" },
filetype="lua",
regtype="l",
},
{
contents= { "some other string" },
filetype="lua",
regtype="l",
},
}
---Get content using {query} if non-nil---@paramquerysqlite_query_select|nil @(look into lua-dev.nvim to get autocomletion)---@returnNeoclipEntry[]functionM:get(query)
localentries=self:__get(query)
-- do some sorting or stuff you need.returnentriesendprint(vim.inspect(M:get()))
returnM
I agree with @kdurant . For what I saw on the example, this library it seems to have pretty advanced and handy ways to manage an sqlite database however it's quite cryptic to read the doc/sqlite.txt file. With the example that @tami5 wrote in this issue my doubts increased instead of being resolved. I hope you consider make a step by step example, it seems to be a really great library I can't really put my hands on it just because I don't have enough information
@JeysonFlores 😆 sorry to hear that, yah. it's a library with a style guide missing. Part of the complexity comes from the fact that this library is both a binding and an opinionated wrapper and there is multiple ways to use it. I'd love to create step by step example to explain it all, but I'm afraid I might not be able to. However, I managed to cleanup and add bookmark manager example
For now checkout powered by sqlite.lua, it's a good place to start for create something powered by sqlite.lua, some use low level api and other uses the wrapper
Repository owner locked and limited conversation to collaborators on Sep 21, 2021
Activity
[-]Can give a example for creating, deleting, updating, selecting?[/-][+]Could give a example for creating, deleting, updating, selecting?[/+]kkharji commentedon Sep 6, 2021
Here's something I just wrote, I will try to include example in the readme soon
kdurant commentedon Sep 7, 2021
@tami5 Thank you for your help.
JeysonFlores commentedon Sep 21, 2021
I agree with @kdurant . For what I saw on the example, this library it seems to have pretty advanced and handy ways to manage an sqlite database however it's quite cryptic to read the
doc/sqlite.txtfile. With the example that @tami5 wrote in this issue my doubts increased instead of being resolved. I hope you consider make a step by step example, it seems to be a really great library I can't really put my hands on it just because I don't have enough informationkkharji commentedon Sep 21, 2021
@JeysonFlores 😆 sorry to hear that, yah. it's a library with a style guide missing. Part of the complexity comes from the fact that this library is both a binding and an opinionated wrapper and there is multiple ways to use it. I'd love to create step by step example to explain it all, but I'm afraid I might not be able to. However, I managed to cleanup and add bookmark manager example
For now checkout powered by sqlite.lua, it's a good place to start for create something powered by sqlite.lua, some use low level api and other uses the wrapper