mirror of
https://github.com/frappe/books.git
synced 2024-11-10 15:50:56 +00:00
1.0 KiB
1.0 KiB
Backends
Frappe.js comes with built-in backends for data storage. These can be client-side or server-side
- SQLite
- REST
There can be only one backend at a time that can be accessed by the frappe.db
property.
API
The backend will implement the following async
methods
get_doc
get_all
get_value
insert
update
sqlite Backend
Connection paramter required for the sqlite backend is the path of the file
sqllite = require('frappejs/frappe/backends/sqlite');
frappe.db = await new sqlite.Database({db_path: db_path})
SQL Queries
You can also directly write SQL with frappe.db.sql
all_todos = frappe.db.sql('select name from todo');
REST Backend
For the client, the backend is the REST API that executes calls with web-requests.
Before using, you must initialize the frappe.fetch
property with window.fetch
or node-fetch
const Database = require('frappejs/frappe/backends/rest_client').Database;
frappe.fetch = window.fetch.bind();
frappe.db = await new Database({server: server});