frappe / frappe/frappe-react-sdk

[Feature Request] Add frappe.db.sql(query, values, as_dict) equivalent in frappe-js-sdk / frappe-react-sdk

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
189
Forks
63
PR merge metrics
No merged PRs in 30d

Description

**Problem Statement**
When building apps with React Native or any JS framework on a Frappe backend, fetching correlated data across multiple DocTypes requires multiple separate API calls followed by manual merging and filtering on the client side.
Example: To display a list of Items with their images and actual stock quantity, a developer must:

Call db.getDocList('Item') → fetch item details like image or any doctype specific field.
Call db.getDocList('Bin') → fetch stock quantities
Manually merge, correlate, and filter both result sets on the client

This is inefficient, error-prone, and increases both network overhead and client-side complexity — especially when the correlation logic is non-trivial (multi-level joins, aggregations, conditional filters across doctypes).

**Proposed Solution**
Expose a db.sql(query, values, as_dict) method in frappe-js-sdk (and a corresponding method and hook in frappe-react-sdk) that maps to Frappe's existing frappe.db.sql(query, values, as_dict).

**Reason for this request**
Reduce dependency of js dev on frappe dev , to write custom whitelisted function for such db opration

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the existing db.getDocList API in frappe-js-sdk and the corresponding hooks in frappe-react-sdk, then compare the requested behavior with Frappe's frappe.db.sql(query, values, as_dict). Define how the method and hook should expose queries and results, including safe handling of values. Done means both SDKs provide the requested equivalent and their usage is documented or tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
api, backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.