refine-sqlite
v1.0.0
Published
SQLite data provider for the refine framework
Downloads
53
Maintainers
Readme
Getting Started
With refine-sqlite you can quickly start creating your app as fast as possible by leveraging the easy-to-use methods powered by refine to interact with your SQLite database.
Features
- Well tested - All the methods are tested using Jest.
- Fully featured - All CRUD operations are supported.
- Synchronous - Everything works synchronously using better-sqlite3.
- Type safe - Written in TypeScript with strict mode enabled.
Installation
npm install refine-sqlite
Usage
- Create a database file. You can use the DB Browser for SQLite to easily create the tables and insert some data, or you can also use the sqlite3 command line shell.
- Import the
dataProvider
function in your file and pass the database file path as a string parameter. - Use the methods to create, update, delete, and get data from your database, filtering and sorting as you wish.
Note
resource
is the name of the table in the database.
import { dataProvider } from "refine-sqlite";
const response = dataProvider("database.db")
.getList({
resource: "posts",
filters: [
{
field: "category_id",
operator: "eq",
value: ["2"],
},
],
sorters: [
{
field: "title",
order: "asc",
},
],
});
console.log(response)
// {
// data: [
// { id: 6, title: 'Dolorem unde et officiis.', category_id: 2 },
// { id: 1, title: 'Soluta et est est.', category_id: 2 }
// ],
// total: 2
// }
Documentation
Development
Clone the repository
git clone https://github.com/mateusabelli/refine-sqlite.git
Install the dependencies
cd refine-sqlite
pnpm install
Build and test
pnpm run build
pnpm run test
Important Before the tests run, the database file
test.db
is deleted and recreated.
Contributing
All contributions are welcome and appreciated! Please create an Issue or Pull Request if you encounter any problems or have suggestions for improvements.
If you want to say thank you or/and support active development of refine-sqlite
- Add a GitHub Star to the project.
- Tweet about the project on Twitter / X.
- Write interesting articles about the project on Dev.to, Medium or personal blog.
- Consider becoming a sponsor on GitHub.
Special Thanks
I'd like to thank refine, my first GitHub sponsor :heart: For believing and supporting my projects!
License
refine-sqlite is free and open-source software licensed under the MIT License.The feather icon is from Phosphor Icons licensed under the MIT License.