This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
Releases: 9ssi7/query
Releases · 9ssi7/query
v0.0.4
Added support for Record<string, string>
and Array<Record<string, string>>
for select function. Now you can give only one object to the select function. The key and value fields of the object are combined with the AS
keyword.
You may be using the LEAST
function to calculate the smallest value of certain columns in SQL, we now have support for the least
function!
You may be using the GROUP_CONCAT
function in SQL often, we now have support for the groupConcat
function!
Here are the additions to the documentation:
select
Select the fields to use for the query
Abstract:
select(fields: Record<string,string> | Array<Record<string, string>> | string | Array<string>) : ISsiQuery;
Using Records:
import { Query } from "@ssibrahimbas/query"
const data = { Id: "userId", FirstName: "firstName" };
const query : string = Query.table("users").select(data).getAll();
// SELECT Id AS userId, FirstName AS firstName FROM users
Using Records With Arrays:
import { Query } from "@ssibrahimbas/query"
const data: Array<Record<string, string>> = [
{ Id: "userId" },
{ FirstName: "firstName" },
];
const query : string = Query.table("users").select(data).getAll();
// SELECT Id AS userId, FirstName AS firstName FROM users
least
Abstract:
least(fields: Array<string>, name?: string | null) : ISsiQuery;
Example:
import { Query } from "@ssibrahimbas/query"
const query : string = Query.table("users").least(["point1", "point2", "point3"], "minPoint").getAll();
// "SELECT LEAST(point1, point2, point3) AS minPoint FROM users"
Single Parameter:
import { Query } from "@ssibrahimbas/query"
const query : string = Query.table("users").least(["point1", "point2", "point3"]).getAll();
// "SELECT LEAST(point1, point2, point3) FROM users"
groupConcat
Abstract:
groupConcat(fields: string, name?: string | null) : ISsiQuery;
Example:
import { Query } from "@ssibrahimbas/query"
const query : string = Query.table("users").groupConcat("UserId", "users").getAll();
// "SELECT GROUP_CONCAT(UserId) AS users FROM users"
Single Parameter:
import { Query } from "@ssibrahimbas/query"
const query : string = Query.table("users").groupConcat("UserId").getAll();
// "SELECT GROUP_CONCAT(UserId) FROM users"