Add javascript function as a substitute to postgresql stored procedures / functions in postgresq
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- JavaScript
- Stars
- 13.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Add an ability for sql.js to apply custom javascript function in the SQL.
Would it be cool to see this in sql.js
CREATE TABLE people_location(
person_id int,
latitude double,
longitude double,
);
-- see people within 5 KM radius
SELECT * FROM people_location WHERE compute_distance(latitude, longitude, my_lat, my_long) <= 5;
function compute_distance(lat1, lon1, lat2, lon2){
var φ1 = lat1.toRadians(), φ2 = lat2.toRadians(), Δλ = (lon2-lon1).toRadians(), R = 6371; // gives d in km
var d = Math.acos( Math.sin(φ1)*Math.sin(φ2) + Math.cos(φ1)*Math.cos(φ2) * Math.cos(Δλ) ) * R;
return d;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by locating how sql.js exposes SQLite functionality to JavaScript, then establish the intended registration and invocation behavior for custom SQL functions. Done means a JavaScript function can be registered, called from SQL, and covered by a focused test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, sqlite
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100