Skip to content
  • Sponsor
  • Notifications You must be signed in to change notification settings
  • Fork 1

Connector for backends created with SQLite.

License

Notifications You must be signed in to change notification settings

mateusabelli/refine-sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2c61b1d · Jun 23, 2024

History

53 Commits
Jun 23, 2024
Dec 3, 2023
Jun 23, 2024
Sep 16, 2023
Aug 30, 2023
Aug 30, 2023
Dec 3, 2023
Dec 3, 2023
Jun 23, 2024
Jun 23, 2024
Aug 30, 2023
Aug 30, 2023
Aug 30, 2023

Repository files navigation

refine-sqlite

Connector for backends created with SQLite.

npm version npm GitHub license Node.js CI


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

  1. 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.
  2. Import the dataProvider function in your file and pass the database file path as a string parameter.
  3. 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

Special Thanks

refine

I'd like to thank refine, my first GitHub sponsor ❤️
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.

Sponsor this project

Sponsor

Packages

No packages published